Apex Wires While Offline

Lightning web components that wire properties or functions to Apex methods continue to provide cached values from the durable store, if available.

If the result of an Apex method hasn’t been retrieved previously and saved to the durable store, an error is returned. The correct way to handle the error depends on whether the Apex method is wired to a property or a function.

When using a property, the wire service either provisions the results to the <property>.data property, or returns an error to the <property>.error property. Use an if:true directive in your component template to check for the presence of each, and render the appropriate output. Changes to <property> trigger a re-render of your component with new values.

With a function, the wire service provisions results to the wired function via an object with either an error or data property. Check for the presence of each in your JavaScript function, and set an appropriate property of your component. This triggers a re-render of your component with new values.

Example code for each of these approaches is available in Wire Apex Methods to Lightning Web Components in the Lightning Web Components Developer Guide.