Salesforce Platform Developer I (legacy) — Question 293
Which two scenarios require an Apex method to be called imperatively from a Lightning web component? (Choose two.)
Answer options
- A. Calling a method that makes a web service callout
- B. Calling a method that is not annotated with cacheable=true
- C. Calling a method with the click of a button
- D. Calling a method that is external to the main controller for the Lighting web component
Correct answer: A, D
Explanation
The correct answers are A and D because calling a method that performs a web service callout (A) requires an imperative call due to the asynchronous nature of callouts. Additionally, if a method is external to the main controller (D), it also necessitates imperative invocation to properly handle the context. Options B and C do not require imperative calls as they can be invoked declaratively.