ZenithRef class
A scoped lifecycle handle for a single node's factory context.
Each node created via ZenithContainer.getOrCreateNode or ZenithContainer.getOrCreate receives its own ZenithRef. The ref provides:
- isMounted — whether the owning container is still alive.
- set — mounted-safe value writes that silently no-op after disposal.
- runAsync — mounted-safe async execution with automatic
AsyncLoading/AsyncData/AsyncErrortransitions. - onDispose — register teardown callbacks that run when the container is disposed.
All methods that mutate state are guarded by isMounted, so callers never need to manually check lifecycle status after async boundaries.
Constructors
- ZenithRef(ZenithContainer container)
-
Creates a ZenithRef bound to
container.
Properties
- container → ZenithContainer
-
The container that owns this ref.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isMounted → bool
-
Whether the owning container is still alive.
no setter
- logger → ZenithLogger
-
Available on ZenithRef, provided by the ZenithLoggerRefX extension
Gets the ZenithLogger for this ref's container.no setter - mediator → ZenithMediator
-
Available on ZenithRef, provided by the ZenithMediatorRefX extension
Gets the ZenithMediator for this ref's container.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDispose(
void callback()) → void -
Registers a
callbackto run when the owning container is disposed. -
onDisposeAsync(
Future< void> callback()) → void - Registers awaited resource cleanup. See ZenithContainer.disposeAsync.
-
read<
T> (ZenithNode< T> node) → T -
Reads the current value of
node. -
registerService(
ZenithService service) → ZenithServiceRegistration -
Available on ZenithRef, provided by the ZenithServiceRefX extension
Starts a service and returns observable lifecycle completion. -
runAsync<
T> (ZenithNode< AsyncValue< node, Future<T> >T> task()) → Future<void> -
Safely runs an async
taskand writes its result tonode, guarding every mutation with this ref's mounted state. -
runAsyncGuarded<
T> (ZenithNode< AsyncValue< node, Future<T> >T> task(), {ConcurrencyStrategy strategy = ConcurrencyStrategy.restartable}) → Future<void> -
Available on ZenithRef, provided by the ZenithConcurrencyX extension
Executestaskand writes its result tonode, guarding against race conditions between overlapping calls according tostrategy. -
runInIsolate<
T, P> (ZenithNode< AsyncValue< node, P payload, T heavyComputation(P payload), {ConcurrencyStrategy strategy = ConcurrencyStrategy.concurrent}) → Future<T> >void> -
Available on ZenithRef, provided by the ZenithIsolateX extension
RunsheavyComputationon a background Isolate via Isolate.run, then writes the result tonodevia runAsyncGuarded. -
runResilient<
T> (ZenithNode< AsyncValue< node, Future<T> >T> task(), {required ZenithResiliencePipeline pipeline}) → Future<void> -
Available on ZenithRef, provided by the ZenithResilienceRefX extension
Runstaskprotected bypipelineand writes the state tonode. -
set<
T> (ZenithNode< T> node, T value) → void -
Safely sets
nodetovalueonly if this ref is still mounted. -
toString(
) → String -
A string representation of this object.
inherited
-
watchStream<
T> (ZenithNode< AsyncValue< node, Stream<T> >T> stream) → StreamSubscription<T> -
Available on ZenithRef, provided by the ZenithStreamX extension
Subscribes tostreamand writes each event tonodeas AsyncData.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited