Should I use Javascript Classes or Apex Classes in Lightning Web Components? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsWant to create select option from ApexAssign value of one field to other field of same object of selected list by clicking a button in list view of objectrepeat rendered for certain conditionHow do I transform SOQL result and output to PageBlockTable?FATAL_ERROR|System.QueryException: List has no rows for assignment to SObjectSLDS classes on (new) base Lightning web components don't workLightning Web Component for table rows and cellsIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?When do @wire methods run (LWC)?Calling apex imperative method in lightning web component needs two click to show data
What font is "z" in "z-score"?
Generate an RGB colour grid
Delete nth line from bottom
Is there such thing as an Availability Group failover trigger?
How would a mousetrap for use in space work?
How do pianists reach extremely loud dynamics?
How to compare two different files line by line in unix?
Crossing US/Canada Border for less than 24 hours
What is the longest distance a player character can jump in one leap?
An adverb for when you're not exaggerating
What is the meaning of the simile “quick as silk”?
If a VARCHAR(MAX) column is included in an index, is the entire value always stored in the index page(s)?
Why are both D and D# fitting into my E minor key?
Does classifying an integer as a discrete log require it be part of a multiplicative group?
How do I make this wiring inside cabinet safer? (Pic)
What does this Jacques Hadamard quote mean?
Is it fair for a professor to grade us on the possession of past papers?
What does "lightly crushed" mean for cardamon pods?
Is safe to use va_start macro with this as parameter?
Amount of permutations on an NxNxN Rubik's Cube
What is the meaning of the new sigil in Game of Thrones Season 8 intro?
Is grep documentation wrong?
How does the math work when buying airline miles?
Should I use a zero-interest credit card for a large one-time purchase?
Should I use Javascript Classes or Apex Classes in Lightning Web Components?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsWant to create select option from ApexAssign value of one field to other field of same object of selected list by clicking a button in list view of objectrepeat rendered for certain conditionHow do I transform SOQL result and output to PageBlockTable?FATAL_ERROR|System.QueryException: List has no rows for assignment to SObjectSLDS classes on (new) base Lightning web components don't workLightning Web Component for table rows and cellsIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?When do @wire methods run (LWC)?Calling apex imperative method in lightning web component needs two click to show data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am working on designing a timesheet Lightning Web Component for my company. Internally, we use a sObject that tracks individual sessions, which then gets rolled up one way to generate payroll, and another way to create invoices. To that end, we don't have a timesheet sObject in our schema (we do have a paystub sObject, but we run payroll every two weeks and collect timesheets every week).
The general flow of what needs to happen is run a SOQL query, transform the data into rows (clients) and columns (dates), and then display the data for viewing and editing. The SOQL clearly happens in an Apex class, and the display is clearly happening in an LWC, but I am unclear about the transformation stage. Would it make sense to have an Apex class gather all the data, transform it, and then @wire the data to the LWC row by row? Or should I just use the Apex class to generate all of the data, @wire a list to the LWC, and use Javascript objects to sort everything into rows and columns?
apex soql lightning-web-components
New contributor
add a comment |
I am working on designing a timesheet Lightning Web Component for my company. Internally, we use a sObject that tracks individual sessions, which then gets rolled up one way to generate payroll, and another way to create invoices. To that end, we don't have a timesheet sObject in our schema (we do have a paystub sObject, but we run payroll every two weeks and collect timesheets every week).
The general flow of what needs to happen is run a SOQL query, transform the data into rows (clients) and columns (dates), and then display the data for viewing and editing. The SOQL clearly happens in an Apex class, and the display is clearly happening in an LWC, but I am unclear about the transformation stage. Would it make sense to have an Apex class gather all the data, transform it, and then @wire the data to the LWC row by row? Or should I just use the Apex class to generate all of the data, @wire a list to the LWC, and use Javascript objects to sort everything into rows and columns?
apex soql lightning-web-components
New contributor
1
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return theList<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.
– Jayant Das
2 days ago
add a comment |
I am working on designing a timesheet Lightning Web Component for my company. Internally, we use a sObject that tracks individual sessions, which then gets rolled up one way to generate payroll, and another way to create invoices. To that end, we don't have a timesheet sObject in our schema (we do have a paystub sObject, but we run payroll every two weeks and collect timesheets every week).
The general flow of what needs to happen is run a SOQL query, transform the data into rows (clients) and columns (dates), and then display the data for viewing and editing. The SOQL clearly happens in an Apex class, and the display is clearly happening in an LWC, but I am unclear about the transformation stage. Would it make sense to have an Apex class gather all the data, transform it, and then @wire the data to the LWC row by row? Or should I just use the Apex class to generate all of the data, @wire a list to the LWC, and use Javascript objects to sort everything into rows and columns?
apex soql lightning-web-components
New contributor
I am working on designing a timesheet Lightning Web Component for my company. Internally, we use a sObject that tracks individual sessions, which then gets rolled up one way to generate payroll, and another way to create invoices. To that end, we don't have a timesheet sObject in our schema (we do have a paystub sObject, but we run payroll every two weeks and collect timesheets every week).
The general flow of what needs to happen is run a SOQL query, transform the data into rows (clients) and columns (dates), and then display the data for viewing and editing. The SOQL clearly happens in an Apex class, and the display is clearly happening in an LWC, but I am unclear about the transformation stage. Would it make sense to have an Apex class gather all the data, transform it, and then @wire the data to the LWC row by row? Or should I just use the Apex class to generate all of the data, @wire a list to the LWC, and use Javascript objects to sort everything into rows and columns?
apex soql lightning-web-components
apex soql lightning-web-components
New contributor
New contributor
New contributor
asked 2 days ago
Andrew FavaloroAndrew Favaloro
333
333
New contributor
New contributor
1
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return theList<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.
– Jayant Das
2 days ago
add a comment |
1
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return theList<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.
– Jayant Das
2 days ago
1
1
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return the
List<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.– Jayant Das
2 days ago
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return the
List<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.– Jayant Das
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
Unless the transformation significantly reduces the amount of data you have to send from the server to the client, it most likely makes sense to do as much as possible in the client (JavaScript). JavaScript is far more efficient in CPU time than Apex, so you'll reduce the overall time the user has to wait for the results to appear. Also, if you decide you later want to provide different options (filtering, sorting, etc), you can avoid network activity entirely by using JavaScript as much as possible, allowing near-instant updates to the page.
1
Adding color to this discussion: ES6.map()
,.filter()
and.reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.
– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257915%2fshould-i-use-javascript-classes-or-apex-classes-in-lightning-web-components%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unless the transformation significantly reduces the amount of data you have to send from the server to the client, it most likely makes sense to do as much as possible in the client (JavaScript). JavaScript is far more efficient in CPU time than Apex, so you'll reduce the overall time the user has to wait for the results to appear. Also, if you decide you later want to provide different options (filtering, sorting, etc), you can avoid network activity entirely by using JavaScript as much as possible, allowing near-instant updates to the page.
1
Adding color to this discussion: ES6.map()
,.filter()
and.reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.
– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
add a comment |
Unless the transformation significantly reduces the amount of data you have to send from the server to the client, it most likely makes sense to do as much as possible in the client (JavaScript). JavaScript is far more efficient in CPU time than Apex, so you'll reduce the overall time the user has to wait for the results to appear. Also, if you decide you later want to provide different options (filtering, sorting, etc), you can avoid network activity entirely by using JavaScript as much as possible, allowing near-instant updates to the page.
1
Adding color to this discussion: ES6.map()
,.filter()
and.reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.
– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
add a comment |
Unless the transformation significantly reduces the amount of data you have to send from the server to the client, it most likely makes sense to do as much as possible in the client (JavaScript). JavaScript is far more efficient in CPU time than Apex, so you'll reduce the overall time the user has to wait for the results to appear. Also, if you decide you later want to provide different options (filtering, sorting, etc), you can avoid network activity entirely by using JavaScript as much as possible, allowing near-instant updates to the page.
Unless the transformation significantly reduces the amount of data you have to send from the server to the client, it most likely makes sense to do as much as possible in the client (JavaScript). JavaScript is far more efficient in CPU time than Apex, so you'll reduce the overall time the user has to wait for the results to appear. Also, if you decide you later want to provide different options (filtering, sorting, etc), you can avoid network activity entirely by using JavaScript as much as possible, allowing near-instant updates to the page.
answered 2 days ago
sfdcfoxsfdcfox
266k13212459
266k13212459
1
Adding color to this discussion: ES6.map()
,.filter()
and.reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.
– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
add a comment |
1
Adding color to this discussion: ES6.map()
,.filter()
and.reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.
– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
1
1
Adding color to this discussion: ES6
.map()
, .filter()
and .reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.– tsalb
2 days ago
Adding color to this discussion: ES6
.map()
, .filter()
and .reduce()
significantly improve UX at the expense of server-side reusability. You can still offload any helpers to a LWC utils file and find client-side reusability there.– tsalb
2 days ago
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
I know that the LWC framework is built on top of ES5, how much of ES6 is available/unavailable?
– Andrew Favaloro
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
@AndrewFavaloro this doc goes in to detail, but essentially, all of ES6 and ES7, most of ES8, and some of ES9.
– sfdcfox
yesterday
add a comment |
Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.
Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.
Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.
Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257915%2fshould-i-use-javascript-classes-or-apex-classes-in-lightning-web-components%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
If I had to design this, I would have created a wrapper class to collect all data within the Apex and then return the
List<MyWrapperClass>
to the LWC. This way I would keep all the logic of fetching/transforming/saving data consolidated at one place.– Jayant Das
2 days ago