What are @wire adapters in LWC and how do they handle reactive parameters?
Suggested answer
@wire connects a component to a data source (Apex method or wire adapter). The wire service calls the adapter whenever reactive parameters change. Syntax: @wire(adapterFunction, { param: '$reactiveProp' }) wiredData; The $ prefix means: when this.reactiveProp changes, re-invoke the wire adapter. The result can be assigned to a property (as an object with data and error properties) or to a function: @wire(getRecord, { recordId: '$recordId', fields }) wiredRecord({ data, error }) { if (data) this.record = data; }. Wire calls are lazy and cached by the LDS cache for platform adapters. A wire parameter without $ is treated as a static value. If a reactive parameter is initially undefined, the wire call is deferred until it has a value.
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.