This schema is quite ilustrative on how the caching mechanism works to improve efficiency in LWC:
Adapters (also called Wired adapters, as they are used with the @wire
decorator) usually are wrappers for the uiApi* APIs, for example the getRecord
adapter is a wrapper for the GET /ui-api/records/{recordId}
call.
The current available adapters are split in these modules uiRecordApi, uiObjectInfoApi, uiRelatedListApi, uiListsApi, uiAppsApi as for Summer ‘23:
Module | Name | Description |
---|---|---|
lightning/uiRecordApi | createRecord | creates a record |
lightning/uiRecordApi | getRecord | get record’s data |
lightning/uiRecordApi | createRecordInputFilteredByEditedFields(recordInput, originalRecord) | creates a RecordInput object with a list of fields that have been edited from their original values to pass in a call to updateRecord(recordInput) . |
lightning/uiRecordApi | deleteRecord(recordId) | deletes a record |
lightning/uiRecordApi | generateRecordInputForCreate(record,objectInfo) | generates a representation of a record (Record Input) that can be used to create a record using createRecord(RecordInput) . Passing in ObjectInfo filters the Record Input to only fields that are createable. |
lightning/uiRecordApi | generateRecordInputForUpdate(record, objectInfo) | generates a representation of a record (Record Input) that can be used to update a record using updateRecord(recordInput) . Passing in ObjectInfo filters the Record Input to only fields that are updateable. |
lightning/uiRecordApi | getFieldValue(record, field) | gets a field’s value from a record. Spanning fields are supported. |
lightning/uiRecordApi | getFieldDisplayValue(record, field) | gets the display value of a field. Spanning fields are supported. |
lightning/uiRecordApi | getRecordCreateDefaults | get default information and data needed to create a record. |
lightning/uiRecordApi | getRecord | get a record’s data. |
lightning/uiRecordApi | getRecords | get data for a batch of records at once. You can request multiple objects or different record types. |
lightning/uiRecordApi | notifyRecordUpdateAvailable(recordIds) | informs LDS that record data has changed so that Lightning Data Service can take the appropriate actions to keep wire adapters updated with the latest record data. Call this function to notify Lightning Data Service that a record has changed outside its mechanisms, such as via imperative Apex or by calling User Interface API via a third-party framework. This function supersedes getRecordNotifyChange(recordIds) . |
lightning/uiRecordApi | updateRecord(recordInput, clientOptions) | updates a record. Provide the record Id of the record to update in recordInput . |
lightning/uiObjectInfoApi | getObjectInfo | get metadata about a specific object. The response includes metadata describing the object’s fields, child relationships, record type, and theme. |
lightning/uiObjectInfoApi | getPicklistValues | use this wire adapter to get the picklist values for a specified field. |
lightning/uiObjectInfoApi | getPicklistValuesByRecordType | get the values for every picklist of a specified record type. |
lightning/uiRelatedListApi | getRelatedListCount | get the RelatedList record count |
lightning/uiRelatedListApi | getRelatedListInfo | get the metadata for RelatedList |
lightning/uiRelatedListApi | getRelatedListInfoBatch | get the metadata for a batch of RelatedLists . |
lightning/uiRelatedListApi | getRelatedListRecords | get RelatedList records. |
lightning/uiRelatedListApi | getRelatedListRecordsBatch | get records for a batch of RelatedLists . |
lightning/uiRelatedListApi | getRelatedListsInfo | get the metadata for RelatedLists in an object’s default layout. |
lightning/uiListsApi | getListInfoByName | get the metadata for a list view. |
lightning/uiListsApi | getListInfosByName | get the metadata for a batch of list views. |
lightning/uiAppsApi | getNavItems (Beta) | get data and metadata for apps displayed in the Salesforce UI. |
Please be aware those are deprecated:
@wire
decoratorThis is the skeleton that is used for using the wire
adapter:
import { adapterId } from 'adapterModule';
@wire(adapterId, adapterConfig)
propertyOrFunction;
adapterId
(Identifier): the identifier of the wire adapter.adapterModule
(String): the identifier of the module that contains the wire adapter function, in the format namespace/moduleName
.
lightning/ui*Api
instead of lightning-ui-*-api
.adapterConfig
(Object): a configuration object specific to the wire adapter. Configuration object property values can be either strings or references to objects and fields imported from @salesforce/schema
.
adapterConfig
object can’t be undefined. If a property is undefined, the wire service doesn’t provision data.renderedCallback()
as it can result in an infinite loop.propertyOrFunction
: a private property or function that receives the stream of data from the wire service.The following code shows how to use the wire
adapter to call an Apex function binding the result to a property: