Watcher<T> class abstract

Interface for watchers that observe changes to reactive sources.

Watchers are similar to effects but provide more control over when they trigger. They compare old and new values and only execute when values actually change (or when a custom condition is met).

Example:

Watcher<List<int>> watcher = Watcher(
  () => [count.value, name.value],
  (newValues, oldValues) => print('Changed'),
);
Implemented types
Implementers

Constructors

Watcher(SourcesFn<T> sourcesFn, WatcherFn<T> fn, {bool immediately, WhenFn<T>? when, JoltDebugFn? onDebug})
Creates a new watcher with the given sources and callback.
factory
Watcher.immediately(SourcesFn<T> sourcesFn, WatcherFn<T> fn, {WhenFn<T>? when, JoltDebugFn? onDebug})
Creates a watcher that executes the callback immediately upon creation.
factory
Watcher.once(SourcesFn<T> sourcesFn, WatcherFn<T> fn, {WhenFn<T>? when, JoltDebugFn? onDebug})
Creates a watcher that executes once and then automatically disposes itself.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Whether this node has been disposed.
no setterinherited
isPaused bool
Whether this watcher is currently paused.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Disposes this node and cleans up resources.
inherited
ignoreUpdates<U>(U fn()) → U
Temporarily ignores updates from the reactive sources during function execution.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCleanUp(Disposer fn) → void
Registers a cleanup function to be called when the watcher is disposed or re-run.
pause() → void
Pauses the watcher, preventing it from responding to changes.
resume([bool tryRun = false]) → void
Resumes the watcher, re-enabling it to respond to changes.
run() → void
Manually runs the watcher function.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

activeWatcher Watcher?
The currently active watcher instance.
getter/setter pair