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 does the "x" in "x86" represent?

Area of a 2D convex hull

Single word antonym of "flightless"

What are the pros and cons of Aerospike nosecones?

Why is black pepper both grey and black?

Antler Helmet: Can it work?

How do I keep my slimes from escaping their pens?

Letter Boxed validator

What causes the vertical darker bands in my photo?

Does surprise arrest existing movement?

How to assign captions for two tables in LaTeX?

Are my PIs rude or am I just being too sensitive?

List *all* the tuples!

How do I stop a creek from eroding my steep embankment?

Is the Standard Deduction better than Itemized when both are the same amount?

How was the dust limit of 546 satoshis was chosen? Why not 550 satoshis?

How to pronounce "criar"?

When to stop saving and start investing?

How widely used is the term Treppenwitz? Is it something that most Germans know?

Should gear shift center itself while in neutral?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

What is a quick way to find the reverse complement in bash

What is this single-engine low-wing propeller plane?

If Jon Snow became King of the Seven Kingdoms what would his regnal number be?



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;








3















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 hours ago

















3















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 hours ago













3












3








3








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 3 hours ago









Andrew FavaloroAndrew Favaloro

183




183




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 hours 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 hours 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 hours 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 hours ago










1 Answer
1






active

oldest

votes


















3














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























  • 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
    43 mins ago











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









3














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























  • 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
    43 mins ago















3














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























  • 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
    43 mins ago













3












3








3







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 hours ago









sfdcfoxsfdcfox

265k13211459




265k13211459












  • 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
    43 mins 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
    43 mins 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
43 mins 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
43 mins ago










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

Oświęcim Innehåll Historia | Källor | Externa länkar | Navigeringsmeny50°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.2213950°2′18″N 19°13′17″Ö / 50.03833°N 19.22139°Ö / 50.03833; 19.221393089658Nordisk familjebok, AuschwitzInsidan tro och existensJewish Community i OświęcimAuschwitz Jewish Center: MuseumAuschwitz Jewish Center

Valle di Casies Indice Geografia fisica | Origini del nome | Storia | Società | Amministrazione | Sport | Note | Bibliografia | Voci correlate | Altri progetti | Collegamenti esterni | Menu di navigazione46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)46°46′N 12°11′E / 46.766667°N 12.183333°E46.766667; 12.183333 (Valle di Casies)Sito istituzionaleAstat Censimento della popolazione 2011 - Determinazione della consistenza dei tre gruppi linguistici della Provincia Autonoma di Bolzano-Alto Adige - giugno 2012Numeri e fattiValle di CasiesDato IstatTabella dei gradi/giorno dei Comuni italiani raggruppati per Regione e Provincia26 agosto 1993, n. 412Heraldry of the World: GsiesStatistiche I.StatValCasies.comWikimedia CommonsWikimedia CommonsValle di CasiesSito ufficialeValle di CasiesMM14870458910042978-6

Typsetting diagram chases (with TikZ?) Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)How to define the default vertical distance between nodes?Draw edge on arcNumerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to place nodes in an absolute coordinate system in tikzCommutative diagram with curve connecting between nodesTikz with standalone: pinning tikz coordinates to page cmDrawing a Decision Diagram with Tikz and layout manager