Offline and last-known-good
Startup
- Read the persisted snapshot and the installation id from storage.
- Resolve the runtime (from
expo-applicationandexpo-updates). readyresolves. From hereflag()answers from the snapshot; before it, from the fallback.- Sync in the background. Rendering never waits on this step.
What is persisted
One entry per key and environment, under @gates/state/<projectKey>/<environment>:
A persisted snapshot is only used when it passes the shape check and its projectKey and environment match the client’s. Storage is anything with get, set and remove; AsyncStorage by default.
The installation id lives under @gates/installation-id, is minted on first launch as inst_ plus 32 hex characters, and is shared across environments so a device is the same device in preview and production.
Last-known-good
- A network error, a timeout, a non-2xx status or a body that fails the SDK’s shape guard sets
status().lastErrorand keeps the previous snapshot. Valid state is never overwritten by an invalid response. { changed: false }marks the cached snapshot as fresh (sourcebecomes"remote") and updatessyncedAt.- A changed snapshot replaces flags, audiences and revision, clears the exposure dedupe, and is written back to storage.
When storage fails
If a read or write throws, the client logs a warning and keeps its state in memory for the rest of the process. Evaluation continues; the next launch starts from whatever storage still holds.
source
| Value | Meaning |
|---|---|
"none" | No snapshot yet. Flags return their fallbacks. Exposure is not recorded. |
"cache" | Evaluating from the persisted snapshot; no successful sync yet this run. |
"remote" | The snapshot has been confirmed or replaced by the API this run. |