I have two different @wire
methods that are calling Apex methods to get different results from two different objects.
After this information has been retrieved by each @wire
respectively, I'd like to afterwards compare the results and set a few other attributes on the page.
How do I achieve this? Should I use connectedCallback()
or renderedCallback()
or neither?
Is there a better way to do multiple Apex method calls then process them afterwards within the JS when the component loads?
I'm hoping there's a graceful way to accomplish this in LWC without having to chain Promises, or having to handle all of this within a single Apex method call.
Best Answer
Option 1: use wire handlers. Instead of writing an Attribute name, you can write a function, and store the data in attributes, then call a common function when both results are available.
Example
Option 2: Use a promise chain. When calling them in order, keep in mind that this will cause a minor performance penalty.