Ingestion Strategies
COLLECTION_ALL ingestion
For a bounded array fetched entirely — the default ingestion type in Flux, and the right choice whenever a collection is small enough to cache and dispatch as one complete payload rather than paginating or evicting it.
Prerequisites
- A store already registered via register() — see api/register
- ingestion/snapshot for the single-object counterpart, ingestion/lru for anything too large to fetch in full
1
Basic usage
Set
ingestionType: 'COLLECTION_ALL' — or simply omit ingestionType entirely, since this is the default.typescript
2
What qualifies as COLLECTION_ALL
Any array you're comfortable fetching, caching, and re-dispatching in full every time — a services list, a team roster, a pricing table. Not something you'd paginate or cap by size.
typescript
3
Shape validation
Because the whole point of this type is a bounded array, Flux checks for one on dispatch.
typescript
4
How it's cached
COLLECTION_ALL shares the same simple storage model as
SNAPSHOT — the full array goes into one envelope under the channel's idbKey, with none of the per-item key splitting LRU channels use.typescript
5
diffBeforeUpdate
Skips dispatching entirely if the incoming array matches what's already cached — useful when a realtime channel fires more often than the underlying data actually changes.
typescript
6
An open question worth confirming: partial realtime updates
The documented realtime contract (
FluxNormalizedEvent) carries one entity per event — an id, an op (CREATE/UPDATE/DELETE), and that single row's data. The spec doesn't lay out how a single-row event is reconciled into a COLLECTION_ALL channel's full array on dispatch — whether Flux merges the row into the cached array internally, or whether the array shape validation in step 3 means a single-row event would actually warn.Flagging this rather than guessing
Rather than invent a merge algorithm the source material doesn't describe, onRealtimeUpdate is the documented, safe place to handle a single-row event yourself if you need array-level reconciliation — worth confirming the exact built-in behavior against the actual dispatchToStore implementation before this section is finalized.
For single-object channels, see ingestion/snapshot. For collections too large to fetch in full, see ingestion/lru. For ingestionType alongside the rest of a registration, see api/register.