What is cacheable true in Apex?
To set cacheable=true, a method must only get data. It can’t mutate data. Marking a method as storable (cacheable) improves your component’s performance by quickly showing cached data from client-side storage without waiting for a server trip.
What is the use of enqueueAction action and call server-side action from client-side?
enqueueAction(action) adds the server-side controller action to the queue of actions to be executed. All actions that are enqueued will run at the end of the event loop.
When to use @ auraenabled variable in Lightning?
@AuraEnabled is used to expose custom classes and methods to Lightning. Static variables will be reset between each transaction, just as they are in Visualforce. Note the following: Don’t store component state in your controller (client-side or server-side).
Can you use a set in an auraenabled method?
You won’t be able to use a Set, but at least you won’t have any surprise with this one. Try to save an AuraEnabled method with a parameter of type Set , and you’ll see the following error message, preventing you to save: Parameter type does not support AuraEnabled: Set . List and Map are working perfectly though.
What does the @ auraenabled annotation do in apex?
The @AuraEnabled annotation enables client- and server-side access to an Apex controller method. Providing this annotation makes your methods available to your Lightning components (both Lightning web components and Aura components). Only methods with this annotation are exposed.
Is the passed attribute null in auraenabled method?
On a side note, remember that with Lightning Data Service you may not even have to query the server anymore to get the record you need. I was not able to use Date in an AuraEnabled method, the passed attribute always ends up being null: However, the workaround is pretty easy to implement, just pass the date as a string, and then cast it to a Date: