reactive_data_manager library

Classes

AbortSignal
A cancellation signal handed to a page fetcher. It is aborted when the request is superseded, invalidated, evicted, cleared or disposed. Wire it to e.g. Dio's CancelToken. Ignoring it is always safe.
DataState<T>
Immutable snapshot of one key of a ReactiveDataManager (or of a ReactiveValue): the value together with its loading, error and freshness flags. It uses the vocabulary of PagedState: the previous data is kept while a fetch runs and after a fetch fails, and errors live here, never as stream errors.
InMemoryReactiveStorage<K, T>
A ReactiveStorage that keeps entries in memory. Useful for tests.
PagedEdge
The state of one end of a list. Has value equality.
PagedEdits<Q, T>
Optimistic edits handed to the optimistic callback of ReactivePagedManager.mutate. They behave like the manager's own patchItem/removeItem/upsertItem, and are undone if the action fails.
PagedError
A failure together with its stack trace. Equal when both are equal.
PagedSnapshot<T>
What is persisted for a query: the first page's items and the server total. Cursors are never persisted (they may expire).
PagedState<T>
Immutable snapshot of a paged list: items plus per-operation flags. Errors live here, next to the retained items; they are never stream errors.
PageRequest<Q, C extends Object>
What a page fetcher is asked for.
PageResult<T, C extends Object>
One fetched page. Named PageResult to avoid clashing with Flutter's Page.
ReactiveDataManager<K, T>
A class that manages reactive data fetching and updating with caching and optimistic updates.
ReactivePagedManager<Q, T, C extends Object>
A manager for paginated lists: one accumulated list per query, with concurrent-safe loadNext/loadPrevious/refresh, dedupe by item id, cross-query item patching, and automatic eviction of unwatched queries.
ReactiveStorage<K, T>
A pluggable persistence layer for ReactiveDataManager.
ReactiveValue<T>
A ReactiveDataManager for a single value that has no natural key (the signed-in user, remote config). It shares the engine with ReactiveDataManager, so join, maxAge, invalidation, watch, storage and the other behaviours are identical; there is just no key parameter.
StoredEntry<T>
A persisted cache entry: the value together with the moment it was fetched.

Enums

PagedEnd
Which end of the list an item is inserted at.
PageDirection
Which part of the list a request is for.
RefreshMode
How refresh rebuilds the list.
Retention
What is kept for a query that has no listeners.

Typedefs

PageFetcher<Q, T, C extends Object> = Future<PageResult<T, C>> Function(PageRequest<Q, C> request)
Fetches one page.

Exceptions / Errors

DataFilteredException
Exception thrown when a first fetched data filter is applied and nothing could be returned in the data stream
OptimisticUpdateException
Exception thrown when a update fails and the data is rolled back
PageCursorExpiredException
Thrown by a fetcher when its cursor is no longer valid. The manager then refreshes the first page instead of reporting an error.
ReactiveDataException
Base class for all exceptions thrown by the reactive data package