ZenithNode<T> class
An atomic, observable state cell holding a value of type T.
Subscribers registered via subscribe (or automatically via ZenithBuilder) are notified through WeakReference-based tracking whenever the value changes. Dead subscribers are automatically pruned during notification passes, preventing memory leaks even if a subscriber forgets to call unsubscribe.
final counter = ZenithNode<int>(0);
counter.set(1); // notifies all subscribers
print(counter.value); // 1
counter.dispose(); // releases all subscribers
- Implementers
- Available extensions
Constructors
-
ZenithNode(T _value, {List<
ZenithMiddleware< middleware = const []})T> > -
Creates a ZenithNode with initial value and optional
middleware.
Properties
- debugSubscriberCount → int
-
The current number of subscribers (including potentially dead weak
references that have not yet been pruned).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether this node has been disposed.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
The current value held by this node.
getter/setter pair
Methods
-
dispose(
{bool purgeZeroize = false}) → void - Permanently disposes this node, clearing all subscribers.
-
guard(
ZenithRef ref, Future< T> future()) → Future<void> -
Available on ZenithNode<
ExecutesAsyncValue< , provided by the SafeAsyncNodeX extensionT> >futureand writes its result to this node, guarding every mutation withref's lifecycle. Equivalent toref.runAsync(this, future). -
invalidate(
) → void - Forces a notification pass without changing the value.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifySubscribers(
) → void - Notifies all live subscribers that this node has changed.
-
set(
T newValue) → void - Sets the value of this node and notifies all active subscribers.
-
subscribe(
ZenithSubscriber subscriber) → ZenithSubscription -
Adds
subscriberto this node's listener set. -
toString(
) → String -
A string representation of this object.
inherited
-
trySet(
T newValue) → bool - Attempts to update the value of this node.
-
unsubscribe(
ZenithSubscriber subscriber) → void -
Removes
subscriberfrom this node's listener set. -
watch(
ZenithRef ref, Stream< T> stream) → StreamSubscription<T> -
Available on ZenithNode<
Subscribes toAsyncValue< , provided by the StreamNodeX extensionT> >streamand writes each event to this node, guarding every mutation withref's lifecycle.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited