fasq_hooks library

Flutter Hooks adapters for the FASQ async data layer.

Exports hook helpers for queries, mutations, prefetching, and parallel requests along with the core fasq APIs.

Classes

AutoRegisterSerializers
Annotation to mark a class for automatic serializer registration.
CacheConfig
Configuration for the query cache.
CacheDataCodecRegistry
Registry of serializers used by cache persistence.
CacheDataCodecResult
Serialized value plus type information.
CacheDataSerializer<T>
Serializer definition for a single cache data type.
CacheEntry<T>
Represents a cached data entry with metadata for staleness and eviction.
CacheInfo
Snapshot of cache state for inspection.
CacheMetrics
Metrics for monitoring cache performance.
CancellationToken
A token that signals when a query operation should be cancelled.
CircuitBreaker
A circuit breaker that prevents repeated execution of operations likely to fail.
CircuitBreakerOptions
Configuration options for a circuit breaker.
CircuitBreakerRegistry
Registry for managing multiple circuit breaker instances with per-endpoint isolation.
CircuitOpenEvent
Event data structure for circuit open events.
CircuitStats
Statistics tracked by a circuit breaker for state transition decisions.
ConsoleExporter
Exports performance snapshots to the developer console.
CursorPagination<TData, TCursor>
Cursor-based pagination configuration.
Dependent<T>
Represents a dependency value that is only usable when enabled is true.
EncryptionProvider
Abstract interface for encryption/decryption operations.
FasqErrorContext
Context information captured when a query fails.
FasqLogger
Logs query and mutation lifecycle events for debugging.
GlobalPerformanceConfig
Global performance configuration for the cache system.
HotCache<T>
A fast-access cache for frequently used items with LRU eviction.
HotCacheOverallStats
Overall statistics for the hot cache
HotCacheStats
Statistics for a specific hot cache entry
InfiniteQuery<TData, TParam>
Manages infinite/paginated data fetching with support for forward and backward pagination.
InfiniteQueryOptions<TData, TParam>
Configuration options for infinite queries.
InfiniteQueryState<TData, TParam>
Immutable state for an infinite query.
IsolatePool
A pool of isolates for executing heavy computation tasks.
IsolatePoolStatus
Status information about an isolate pool
IsolateTask<T, R>
A task wrapper for isolate execution.
JsonExporter
Exports performance snapshots as JSON payloads.
MemoryPressureHandler
Handles system memory pressure warnings.
MetricsConfig
Configuration for managing multiple metrics exporters and export settings.
MetricsExporter
Contract for exporting performance snapshots to external sinks.
Mutation<T, TVariables>
Executes and tracks a mutation with optional offline queueing.
MutationBuilder<T, TVariables>
A widget that builds UI from the state of a mutation.
MutationHandler<TData, TVariables>
Executes a registered mutation type with typed variables.
MutationMeta
Metadata for mutation side effects and user-facing messages.
MutationOptions<T, TVariables>
Configuration options for mutation behavior and lifecycle callbacks.
MutationSnapshot<TData, TVariables>
Snapshot of a mutation transition at a specific point in time.
MutationState<T>
Immutable state model for a mutation lifecycle.
MutationTypeRegistry
Global registry that maps mutation type names to execution handlers.
NamedQueryConfig<T>
Named configuration for queries
NetworkStatus
In-memory network connectivity state notifier.
OfflineMutationEntry
Persisted representation of a queued offline mutation.
OfflineQueueManager
Manages persistence and processing of offline mutation queue entries.
OpenTelemetryExporter
Exports performance snapshots in OpenTelemetry (OTLP) JSON format.
Page<TData, TParam>
Snapshot of a single page in an infinite query.
PageNumberPagination<TData>
Page-number based pagination configuration.
PerformanceMonitor
Centralized performance monitoring service.
PerformanceOptions
Performance configuration options for a query.
PerformanceReport
Detailed performance report with comprehensive metrics.
PerformanceSnapshot
Snapshot of performance state at a specific point in time.
PerformanceSummary
Quick performance summary for monitoring dashboards
PersistenceOptions
Configuration options for cache persistence.
PersistenceProvider
Abstract interface for encrypted data persistence operations.
PrefetchConfig<T>
Configuration describing a query to prefetch.
Query<T>
A query represents an async operation with managed state and lifecycle.
QueryBuilder<T>
A widget that executes an async operation and builds UI based on its state.
QueryCache
Core cache storage and management for queries.
QueryClient
Global registry for all queries in the application.
QueryClientObserver
Observer hooks for query and mutation lifecycle events.
QueryClientProvider
Provider widget for QueryClient configuration.
QueryConfig<T>
Configuration for a single query in a parallel query setup.
QueryDebugInfo
Debug information for a Query instance (debug mode only).
QueryDependencyManager
Manages parent-child relationships between queries.
QueryKey
Base type for stable query identifiers used by the cache/client registry.
QueryMeta
Describes optional metadata for query lifecycle side effects.
QueryMetrics
Metrics for a specific query's performance.
QueryOptions
Configuration options for a query.
QuerySnapshot<T>
Immutable state transition snapshot emitted by a query update.
QueryState<T>
Represents the current state of a query.
SecurityPlugin
Abstract interface for security plugins.
SecurityProvider
Abstract interface for secure key storage operations.
StringQueryKey
Query key backed by a plain string value.
ThroughputMetrics
Metrics representing query throughput over a time window.
TypedQueryKey<T>
A QueryKey that carries an associated result type.
UseMutationResult<TData, TVariables>
Convenience wrapper returned by useMutation.

Enums

CircuitState
The state of a circuit breaker.
EvictionPolicy
Policy for selecting which cache entries to evict when memory limit is reached.
MutationStatus
Lifecycle status of a mutation operation.
QueryStatus
The status of a query's lifecycle.

Extensions

JsonSerializableRegistry on CacheDataCodecRegistry
Helper registration APIs for JSON-serializable models.
QueryClientContext on BuildContext
Extension on BuildContext to easily access QueryClient.
StringQueryKeyExtension on String
Converts strings to QueryKey instances.

Functions

logCircuitOpenEvent(CircuitOpenEvent event) → void
Default logging callback for circuit open events.
useInfiniteQuery<TData, TParam>(QueryKey queryKey, Future<TData> queryFn(TParam param), {InfiniteQueryOptions<TData, TParam>? options}) InfiniteQueryState<TData, TParam>
Observes an InfiniteQuery from a HookWidget and returns its state.
useMutation<TData, TVariables>(Future<TData> mutationFn(TVariables variables), {void onSuccess(TData data)?, void onError(Object error)?}) UseMutationResult<TData, TVariables>
Creates a FASQ Mutation and exposes its state through a hook.
useNamedQueries(List<NamedQueryConfig> configs) Map<String, QueryState>
Hook for named queries with map-based access
usePrefetchOnMount(List<PrefetchConfig> configs, {QueryClient? client}) → void
Hook that prefetches queries on mount.
usePrefetchQuery<T>({QueryClient? client}) → void Function(QueryKey, Future<T> (), {QueryOptions? options})
Hook that provides a callback to prefetch queries.
useQueries(List<QueryConfig> configs, {QueryClient? client}) List<QueryState>
Hook that executes multiple queries in parallel and returns their states.
useQuery<T>(QueryKey queryKey, Future<T> queryFn(), {QueryOptions? options, QueryClient? client}) QueryState<T>
Watches a single query inside a HookWidget and returns its state.
useQueryClient({QueryClient? client}) QueryClient
Returns the ambient QueryClient instance for hook-enabled widgets.
whenReady<T, R>(QueryState<T> state, R selector(T value)) → R?
Applies selector only when state is ready with non-null data.

Typedefs

CacheDataDecoder<T> = T Function(Object? value)
Decodes a JSON-safe object back into a typed cache value.
CacheDataEncoder<T> = Object? Function(T value)
Encodes a typed cache value into a JSON-safe object.
CircuitOpenCallback = void Function(CircuitOpenEvent event)
Callback function signature for circuit open events.
CursorSelector<TData, TCursor> = TCursor? Function(TData pageData)
Extracts a pagination cursor from page data.
FasqErrorReporter = void Function(FasqErrorContext context)
Callback for reporting query errors to external systems.
GetNextPageParam<TData> = int? Function(TData lastPageData, int pageCount)
Computes the next page number from page data and loaded page count.
GetPrevPageParam<TData> = int? Function(TData firstPageData, int pageCount)
Computes the previous page number from page data and loaded page count.
MemoryPressureListener = void Function({required bool critical})
Callback used for memory pressure notifications.

Exceptions / Errors

CancelledException
Exception thrown when a query operation is cancelled.
CircuitBreakerOpenException
Exception thrown when a request is made to an open circuit breaker.
IsolateExecutionException
Exception thrown when isolate execution fails.
IsolateTaskCancelledException
Exception thrown when an isolate task is cancelled.