Suggested answer

@wire with Apex: The Apex method must be annotated @AuraEnabled(cacheable=true) for wire use. The LWC imports it: import getAccounts from '@salesforce/apex/AccountController.getAccounts'; Then: @wire(getAccounts, { searchTerm: '$searchTerm' }) wiredAccounts; The $ prefix makes parameters reactive — changing searchTerm re-calls the method. Wire adapters: Platform-provided adapters (getRecord, getPicklistValues, etc.) from lightning/uiRecordApi, lightning/uiObjectInfoApi. They handle caching, network requests, and reactive updates automatically. Imperative Apex: Call Apex as a Promise: getAccounts({ searchTerm: this.searchTerm }).then(result => { this.data = result; }).catch(error => { ... }); Use imperative when: the call is event-triggered (not on load), the Apex method has side effects (DML), or the method is not cacheable.

Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.

Community comments (0)

No comments yet.

Sign in or create a free account to add a comment. Comments are moderated before they appear.

Plain text only, 3–2000 characters. A moderator reviews every comment before it is published.