createGates (outside React)
The Expo createGates sets up AsyncStorage, the runtime from expo-application and expo-updates, and an AppState listener that calls onForeground() when the app becomes active. destroy() removes the listener, flushes telemetry and stops timers.
The client
| Member | What it does |
|---|---|
ready | A promise that resolves once the local snapshot has been read (or found absent). Never waits on the network. |
flag(key, fallback?) | Synchronous, local, never throws, never fetches. fallback answers when the flag is unknown. |
explain(key) | The same decision with its reasons. See explain(). |
identify(user) | Attach a user. See identify and reset. |
reset() | Forget the user. |
refresh() | Force a sync. Resolves true when the snapshot changed. See Refresh. |
adopt(key) | Record that the person used the feature behind key. |
status() | The current GatesStatus. |
subscribe(listener) | Called on any change (snapshot, user, status). Returns the unsubscribe function. |
onForeground() | Refreshes if refreshIntervalMs has elapsed since the last sync attempt; otherwise flushes telemetry. |
destroy() | Flush telemetry and stop timers. |
Splash screen (optional)
The SDK never blocks rendering. If you would rather not render the fallback for the first frame, wait for ready. It resolves after the local read and never waits on the network:
@gates/expo/core
The same client with no React, React Native or Expo imports, for Node, web, Jest and vitest. runtime is required there (an object or a function returning one, sync or async), storage defaults to memory, and fetch can be swapped for a fake. It also exports createMemoryStorage, DEFAULT_API_URL, DEFAULT_REFRESH_INTERVAL_MS, IDENTIFY_SYNC_DELAY_MS, SDK_VERSION, stateKey and INSTALLATION_ID_KEY.