A Lightning component has a wired property, searchResults, that stores a list of Opportunities. Which definition of the Apex method, to which the searchResults property is wired, should be used?
A. @AuraEnabled(cacheable=true)
public static List search(String term) { /* implementation*/ }
B. @AuraEnabled(cacheable=true) public List search(String term) {
/*implementation*/ }
C. @AuraEnabled(cacheable=false) public static List search(String term) {
/*implementation*/ }
D. @AuraEnabled(cacheable=false) public List search(String term) {
/*implementation*/ }
A. @AuraEnabled(cacheable=true)
public static List search(String term) { /* implementation*/ }
Explanation:
Since the Lightning component uses a wired property, the Apex method must:
✅ Be cacheable → cacheable=true ensures improved performance by allowing the Lightning framework to store and reuse data without unnecessary Apex calls.
✅ Be static → Wired properties expect static methods that do not rely on instance-specific data.
✅ Return a List of Opportunities → Since searchResults stores a list of Opportunity records, the method must return List rather than a generic List.