Understand Fetcher Store states
mainA fetcher store's state depends on whether it is the first fetch, if it has stale data in cache, or if it is currently loading.
| State | loading | data | error | promise | When |
|---|---|---|---|---|---|
| Initial (no subscribers) | false | — | — | — | Before any component subscribes |
| Loading (no cache) | true | — | — | Promise | First fetch, or after invalidate |
| Loading (stale cache) | true | Previous data | — | Promise | Refetch when cacheLifetime cache exists |
| Success | false | T | — | — | Fetcher resolved |
| Error | false | Previous data or — | E | — | Fetcher rejected |
| Conditional fetch disabled | false | — | — | — | Any key part is null/undefined/false |
| Deduplicated (from cache) | false | T | — | — | Same key fetched within dedupeTime |
Key behaviors:
invalidatewipes the cache entirely (returns to "Loading (no cache)").revalidatemarks the cache as stale (returns to "Loading (stale cache)" with previous data visible).- When the store loses all subscribers (
onStop), it resets to the initial state.