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;








6















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?










share|improve this question







New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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

















6















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?










share|improve this question







New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 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













6












6








6








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?










share|improve this question







New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question







New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Andrew FavaloroAndrew Favaloro

333




333




New contributor




Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Andrew Favaloro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 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












  • 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







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










1 Answer
1






active

oldest

votes


















5














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.






share|improve this answer


















  • 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











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.









draft saved

draft discarded


















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









5














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.






share|improve this answer


















  • 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















5














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.






share|improve this answer


















  • 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













5












5








5







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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












  • 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










Andrew Favaloro is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form