Newer Version Available
Reactive Apex Wires
Read the details in Wire Apex Methods to Lightning Web Components in the Lightning Web Components Developer Guide.
- @wire adapters are read-only.
- When you use @wire adapters, you don’t call your Apex method directly. Instead, the framework decides when to call it, when it needs the value of the property or function connected to the @wire. This can happen more or less frequently than you expect.
- Your Apex method must not make server-side changes when called by the @wire service.
- The result of calling your Apex method is cached on the client. See important details in Apex Results Are Separate from Other Primed Data.
These points are standard behavior for Lightning web components. They aren’t specific to the additional mobile and offline features of an offline-enabled mobile app.
What is different is the cache. The mobile app saves the results of @wire calls to Apex methods in a durable store, instead of an in-memory cache. The durable store is longer-lived than the standard cache used by Lightning web components. The standard cache is designed for performance, rather than offline use. The durable store, in contrast, is designed specifically for offline use. It survives client app restarts, and even device restarts. Data in the durable store is available to provide a result for an Apex method call, even when offline. Again, see considerations in Apex Results Are Separate from Other Primed Data.