API Reference
invalidate()
Removes a single channel's cached entry from IndexedDB. The narrowest tool in the engine — one targeted key removal, nothing else — for the cases where you know exactly one store's disk cache is wrong and want it gone before the next read.
Prerequisites
- flux created via createFlux() — see api/create-flux
- A store already registered under the channel you're invalidating — see api/register
1
Basic usage
Call
flux.invalidate(channel) with the channel name you registered the store under. It returns a promise that resolves once the IDB entry is gone.typescript
2
What it does under the hood
Internally this is a thin wrapper over
idbDelete — the same primitive flux.destroy() and the multi-tenant sweep routines use elsewhere, called here for exactly one key rather than a prefix-matched batch.typescript
3
Scope-aware resolution
Because it resolves the key the same way every other IDB call in Flux does, invalidating a
'user'-scoped channel only ever touches the currently active user's namespaced entry — never another tenant's copy of the same channel name.typescript
4
This is not a refetch
invalidate() only deletes what's cached — it never fires a network request on its own. Pair it explicitly with a bootstrap() call if you want fresh data immediately, or leave the channel cold and let it repopulate the next time bootstrap runs.typescript
5
FluxErrorBoundary — the built-in consumer
The most common caller of
invalidate() isn't application code at all — it's FluxErrorBoundary in flux-react, which catches a data-shape crash from a malformed cached payload and clears it automatically.typescript
Reach for this before a manual IDB clear
If you're debugging a store stuck on stale or malformed cached data, invalidate(channel) is the targeted equivalent of clearing that one IDB entry by hand in devtools — without needing to know the resolved key shape yourself.
For clearing every channel belonging to a logged-out user at once, see api/clear-user-session. For repopulating a channel after invalidating it, see api/bootstrap.