ZenithConfigNode<T> class

A strongly-typed configuration node that parses dynamic JSON/Map payloads (e.g. from Remote Config, local assets, or feature flags) into type T.

Equivalent to the Options Pattern (IOptionsMonitor<T>) in ASP.NET Core.

final appConfigNode = ZenithConfigNode<AppConfig>(
  key: 'app_options',
  initialConfig: const AppConfig(),
  decoder: AppConfig.fromJson,
);
appConfigNode.updateRaw({'api_endpoint': 'https://v2.api.com'});
Inheritance
Available extensions

Constructors

ZenithConfigNode({required String key, required T initialConfig, required T decoder(Map<String, dynamic> json)})
Creates a ZenithConfigNode with initial initialConfig and decoder.

Properties

debugSubscriberCount → int
The current number of subscribers (including potentially dead weak references that have not yet been pruned).
no setterinherited
decoder → T Function(Map<String, dynamic> json)
The decoder callback parsing a Map<String, dynamic> into T.
final
hashCode → int
The hash code for this object.
no setterinherited
isDisposed → bool
Whether this node has been disposed.
no setterinherited
key → String
The key used for identifying this configuration node.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value ↔ T
The current value held by this node.
getter/setter pairinherited

Methods

dispose({bool purgeZeroize = false}) → void
Permanently disposes this node, clearing all subscribers.
inherited
guard(ZenithRef ref, Future<T> future()) → Future<void>

Available on ZenithNode<AsyncValue<T>>, provided by the SafeAsyncNodeX extension

Executes future and writes its result to this node, guarding every mutation with ref's lifecycle. Equivalent to ref.runAsync(this, future).
invalidate() → void
Forces a notification pass without changing the value.
inherited
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.
inherited
set(T newValue) → void
Sets the value of this node and notifies all active subscribers.
inherited
subscribe(ZenithSubscriber subscriber) → ZenithSubscription
Adds subscriber to this node's listener set.
inherited
toString() → String
A string representation of this object.
inherited
trySet(T newValue) → bool
Attempts to update the value of this node.
inherited
unsubscribe(ZenithSubscriber subscriber) → void
Removes subscriber from this node's listener set.
inherited
updateRaw(Map<String, dynamic> json) → bool
Attempts to parse json into T using decoder and updates the node value.
watch(ZenithRef ref, Stream<T> stream) → StreamSubscription<T>

Available on ZenithNode<AsyncValue<T>>, provided by the StreamNodeX extension

Subscribes to stream and writes each event to this node, guarding every mutation with ref's lifecycle.

Operators

operator ==(Object other) → bool
The equality operator.
inherited