CacheScope<Q extends Accessor> class
Typed, imperative access to the cache — outside a widget build, in an
optimistic: callback, after await client.mutate(...). Get one from
SlingClient.cacheScope; the generator adds one method per keyed type
(extension SlingCacheAccess on CacheScope<Query>: launch(id), …).
The accessors it hands out are the ordinary generated classes, bound to this scope:
- reads never fetch — a field that is not cached reads as
null(objects as skeletons, see Accessor.isSkeleton) and nothing is sent; - writes (generated setters, CacheList edits) go through the
normal write path: dependent scopes rebuild, and inside a mutation's
optimisticcallback they are journaled and undone on failure.
A scope records nothing that outlives it: deps is always empty (it never rebuilds) and misses are ignored. Scopes are cheap; take a fresh one per use.
- Implemented types
Constructors
-
CacheScope(SlingClient<
Q> client)
Properties
- cache → Cache
-
no setteroverride
-
client
→ SlingClient<
Q> -
final
-
deps
→ Set<
String> -
Always a fresh empty set: a cache scope never rebuilds.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- operation → String
-
query,mutationorsubscription.no setteroverride - query → Q
-
The typed query root, reading from the cache only:
cacheScope.query.me. Root fields that were never fetched read as skeletons — check Accessor.isSkeleton before writing through one, or the write creates a partial object the next fetch has to merge into.no setter - root → Selection
-
Root of the selection tree recorded in the current scope.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
typePolicies
→ Map<
Type, TypePolicy> -
The client's field policies (
SlingClient.typePolicies), keyed by the generated accessor class a field is read through.no setteroverride
Methods
-
entity<
T extends Accessor> (String typename, Object id, T ctor(Recorder, Selection, List< Object> )) → T? -
The cached entity
typename:idas aT(viactor, the generated constructor tear-off), ornullwhen it is not in the cache — never a skeleton, and never a request. Keys are resolved with Normalization.lookup, so with Normalization.none this is alwaysnull. Generated code wraps it:cacheScope.launch('launch-181'). -
evict(
Accessor entity) → bool -
Removes
entityfrom the cache everywhere: its entity is dropped, every list that referenced it loses the element, and object fields pointing at it read as missing again (re-fetched on the next build). Dependent scopes rebuild. Returnsfalsewhen it was not cached. -
list<
R extends Accessor> (List< R> ? select(Q query)) → CacheList<R> -
The cached list
selectreturns, for membership edits: -
locateList(
List< Object> path, List<Accessor> ? value) → void -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMiss(
Selection leaf) → void -
Reads through a cache scope never fetch.
override
-
onWrite(
CacheWrite write) → void -
Called on manual writes (generated setters) so dependants can be
re-rendered and, during a mutation's optimistic phase, so the write can
be undone if the mutation fails.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited