Skip to content

Commit 7bb9855

Browse files
committed
docs: simplify context, refresh and cache sections
1 parent c34e870 commit 7bb9855

3 files changed

Lines changed: 24 additions & 26 deletions

File tree

‎packages/browser-sdk/README.md‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,25 @@ await reflag.setContext({
6161
await reflag.refresh();
6262
```
6363

64-
`setContext()` replaces the context; update methods shallow-merge their section. User/company sections require IDs, including valid numeric zero. Context supports nested JSON and arrays. A context change clears the old context's values while fetching; stale/in-flight responses cannot replace a newer context or snapshot.
65-
66-
Values come from `GET /flags/evaluated`, not legacy `/features/evaluated`. Server evaluation retains the complete internal graph and authorized public roots. The Browser SDK does not cache dependency evaluations of its own.
64+
`setContext()` replaces the whole context. The update methods merge new attributes into the user, company or other context. Users and companies need an `id`. While flags for a new context load, reads return their defaults.
6765

6866
Constructor options include:
6967

70-
| Option | Behavior |
71-
| ------------------------------- | --------------------------------------------------------------------------- |
72-
| `apiBaseUrl`, `appBaseUrl` | API origin and toolbar/feedback links |
73-
| `credentials` | Fetch credentials mode; `include` also enables default SSE credentials |
74-
| `timeoutMs` | Flag request timeout; default 5,000 ms |
75-
| `staleTimeMs` | Fresh-cache duration; default 0 |
76-
| `staleWhileRevalidate` | Serve stale cached state while revalidating; default false |
77-
| `expireTimeMs` | Cache expiry; default 30 days |
78-
| `storage` | Optional async storage adapter |
79-
| `enableLiveFlagUpdates` | Refresh after SSE publications; default false in Browser, true in React/Vue |
80-
| `eventSourceFactory` | Optional EventSource-compatible transport |
81-
| `trackingQueue` | Buffered-delivery `flushDelayMs` and `maxSize` |
82-
| `logger`, `toolbar`, `feedback` | Logging, Boolean override toolbar and feedback options |
83-
84-
Evaluated cache and override storage use isolated v2 keys. V1 cache entries are never interpreted as v2 values. Malformed refreshes leave known-good state intact. Valid saved v2 selections retain their real provenance on restore. There is no automatic periodic HTTP fallback after an SSE failure; manual refresh/context updates remain available.
68+
| Option | Behavior |
69+
| ------------------------------- | -------------------------------------------------------------------------------------------------- |
70+
| `apiBaseUrl`, `appBaseUrl` | API origin and toolbar/feedback links |
71+
| `credentials` | Fetch credentials mode |
72+
| `timeoutMs` | Flag request timeout; default 5,000 ms |
73+
| `staleTimeMs` | Fresh-cache duration; default 0 |
74+
| `staleWhileRevalidate` | Serve stale cached state while revalidating; default false |
75+
| `expireTimeMs` | Cache expiry; default 30 days |
76+
| `storage` | Optional async storage adapter |
77+
| `enableLiveFlagUpdates` | Update flags as soon as they change in Reflag; default `false` in Browser, `true` in React and Vue |
78+
| `eventSourceFactory` | Custom EventSource implementation for live updates |
79+
| `trackingQueue` | How long to batch events (`flushDelayMs`) and the batch size (`maxSize`) |
80+
| `logger`, `toolbar`, `feedback` | Logging, toolbar and feedback options |
81+
82+
Flags are cached in the browser. If a refresh fails, the client keeps the last values it received.
8583

8684
## Overrides and toolbar
8785

‎packages/react-sdk/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ To use a client you create yourself, pass it to `ReflagClientProvider`. Your app
128128

129129
## Context, loading and events
130130

131-
- `useUpdateUser()`, `useUpdateCompany()` and `useUpdateOtherContext()` return async shallow-update functions. `useClient().setContext(context)` replaces the whole context.
132-
- Context changes clear old-context values while fetching. Stale/in-flight responses cannot replace a newer context/snapshot.
133-
- `useIsLoading()` returns provider loading state. `loadingComponent` and `initialLoading` configure initial presentation; they are not getter arguments.
134-
- `useClient()` returns the underlying Browser client. Its `getFlags()` returns all flag values; `getFlagResults()` is diagnostic-only.
131+
- `useUpdateUser()`, `useUpdateCompany()` and `useUpdateOtherContext()` return functions that merge new attributes into the current context. `useClient().setContext(context)` replaces the whole context.
132+
- While flags for a new context load, reads return their defaults.
133+
- `useIsLoading()` returns provider loading state. Use `loadingComponent` or `initialLoading` to control what renders while flags load.
134+
- `useClient()` returns the underlying Browser client.
135135
- `useOnEvent(type, handler, client?)` subscribes and unsubscribes on unmount. A supplied external client works without a provider.
136136

137137
## Opt-in hooks

‎packages/vue-sdk/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ The ref updates when flag values change. Each read records a check, which Reflag
6464

6565
## Loading, context and client access
6666

67-
- `useIsLoading()` returns a Boolean ref for provider loading; the `#loading` slot and `initialLoading` control initial presentation.
68-
- `useUpdateUser()`, `useUpdateCompany()` and `useUpdateOtherContext()` return async shallow-update functions.
69-
- `useClient()` exposes the Browser client, including `setContext(context)`, `refresh()` and `setFlagOverride(key, value)`. Undefined clears an override; null is a JSON override.
67+
- `useIsLoading()` returns a Boolean ref for provider loading; use the `#loading` slot or `initialLoading` to control what renders while flags load.
68+
- `useUpdateUser()`, `useUpdateCompany()` and `useUpdateOtherContext()` return functions that merge new attributes into the current context.
69+
- `useClient()` exposes the Browser client, including `setContext(context)`, `refresh()` and `setFlagOverride(key, value)`. Pass `undefined` to remove an override.
7070
- `getFlags()` returns all flag values and records a check for each.
7171
- `useOnEvent(type, handler, client?)` subscribes on mount and unsubscribes on unmount. An external client may be supplied explicitly.
7272

73-
A context change clears old values while fetching. Late responses for previous contexts or lower snapshot versions cannot replace accepted state. V2 cache/override storage is isolated from v1. Browser fetching uses `/flags/evaluated` and never re-evaluates/caches dependencies locally.
73+
While flags for a new context load, reads return their defaults.
7474

7575
## Bootstrap
7676

0 commit comments

Comments
 (0)