QueryNamespace class final Typed queries
A key prefix that groups query definitions, such as everything about devices.
A namespace claims no data type: the entries under it may hold anything. So it can invalidate, refetch, cancel, reset and remove them, and it has no read and no write. Each definition is given the namespace it belongs to, and its keys start with the namespace's parts.
final devices = QueryNamespace(['devices']);
final detail = QueryFamily<String, Device>(
namespace: devices,
name: 'detail',
queryFn: (id, context) => api.device(id),
);
await devices.invalidate(client); // every entry under ['devices']
Whatever changes what a query returns belongs in its key, and a
namespace is a natural place for the part that is the same for a whole
group: QueryNamespace(['tenant', tenantId, 'devices']).
- Inheritance
-
- Object
- QueryTarget
- QueryNamespace
Constructors
-
QueryNamespace(List<
Object?> parts) -
The namespace of every key that starts with
parts. The parts follow QueryKey's rules: collections are frozen, and an object needs value equality.
Properties
Methods
-
cancel(
QueryClient client, {bool revert = true, bool silent = false}) → Future< void> -
Cancels the fetches in flight for the selected entries:
QueryClient.cancelQueries over this target. An optimistic update
calls this first, so that a response on its way cannot overwrite the
value it is about to write.
inherited
-
filters(
{QueryTypeFilter? type, bool? stale, FetchStatus? fetchStatus, QueryStatus? status, bool predicate(Query< Object?> query)?}) → QueryFilters -
The filters that select this target, for everything that takes
QueryFilters: the client's bulk operations,
QueryClient.isFetching, a cache listener.inherited -
invalidate(
QueryClient client, {RefetchType? refetchType, bool cancelRefetch = true}) → Future< void> -
Marks every selected entry stale and refetches the ones in use:
QueryClient.invalidateQueries over this target, with its parameters.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refetch(
QueryClient client, {bool cancelRefetch = true}) → Future< void> -
Refetches every selected entry that can fetch:
QueryClient.refetchQueries over this target.
inherited
-
remove(
QueryClient client) → void -
Removes every selected entry from the cache:
QueryClient.removeQueries over this target. Removing a reference's
entry is how a rollback restores "nothing was cached".
inherited
-
reset(
QueryClient client, {bool cancelRefetch = true}) → Future< void> -
Puts every selected entry back to its initial state and refetches the
ones in use: QueryClient.resetQueries over this target.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited