StateHandle<V> typedef
StateHandle<V> = ({ValueCell<V> cell, Future<void> Function(Pulse<V> pulse, {bool serializedCompletion}) ingest, bool Function(V? value) update, Future<bool> Function(V? value) updateAsync})
A management record that bundles a ValueCell with its imperative update functions — the standard way to create and interact with a state atom.
When to use
You get this from Cell.state. It gives you:
cell: the reactive state container (read‑only observation).update: a synchronous function to update the state.updateAsync: an asynchronous, lock‑protected version ofupdate.ingest: a low‑level entry point for full Pulse injection.
How it works
The handle separates the observable cell (safe to share) from the mutation functions (keep them private to the owner). This enforces a strict write‑privilege model – observers can only read, the owner can write.
Type Parameters:
V: The type of the value managed by this state handle.
Implementation
typedef StateHandle<V> = ({
/// The persistent, observable reactive node.
ValueCell<V> cell,
/// Synchronously emits a state transition.
///
/// Returns `true` if the value was successfully committed. A no-op
/// update (a value `identical` to or `==` the current state) is
/// deduplicated: nothing is emitted and `false` is returned — a skipped
/// update is deliberately not a commit.
bool Function(V? value) update,
/// Asynchronously emits a state transition, ensuring atomic
/// serialization through the cell's synchronization lock.
Future<bool> Function(V? value) updateAsync,
/// The primary ingress handle for direct signal orchestration.
///
/// Set `serializedCompletion` to `true` to wait for the entire reactive
/// graph to reach a stable state before the future completes.
Future<void> Function(Pulse<V> pulse, {bool serializedCompletion}) ingest
});