AsyncSignal<T> class

Reactive state for a Future or Stream operation.

Signal reads performed synchronously by the source factory are tracked. Changing one of those dependencies automatically reloads the operation.

Inheritance

Constructors

AsyncSignal.fromFuture(Future<T> futureFn(), {String? name, bool autoDispose = false, void onDispose()?, FutureOr<void> onCancel()?})
Creates an AsyncSignal from a Future factory.
AsyncSignal.fromStream(Stream<T> streamFn(), {String? name, bool autoDispose = false, void onDispose()?, FutureOr<void> onCancel()?})
Creates an AsyncSignal from a Stream factory.

Properties

autoDisposeEnabled bool
Whether this signal should automatically dispose of its resources when it has no observers.
getter/setter pairinherited
data → T?
no setter
hasData bool
no setter
hasError bool
no setter
hashCode int
The hash code for this object.
no setterinherited
hasValue bool
no setter
isDisposed bool
Tracks whether the signal is currently in a disposed state.
getter/setter pairinherited
isLoading bool
no setter
isRefreshing bool
Whether previous data is being retained during a refresh.
no setter
isReloading bool
Alias for isRefreshing.
no setter
name String?
Optional name for debugging and observation.
finalinherited
observers Set<Consumer>
The set of active consumers currently observing this node.
finalinherited
onDisposeCallback ↔ void Function()?
Callback executed when this signal is disposed (e.g. observers drop to 0 under autoDispose).
getter/setter pairinherited
onListenCallback ↔ void Function()?
Callback executed when this signal is first observed or revived after auto-disposal.
getter/setter pairinherited
requireValue → T
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value AsyncValue<T>
Gets the current value of the signal.
getter/setter pairinherited
valueOrNull → T?
no setter

Methods

addChangeListener(void listener(AsyncValue<T> previous, AsyncValue<T> current)) → void
Registers a lightweight value-change callback that does not count as a reactive observer for auto-disposal.
inherited
addDependency(Node node) → void
Registers a node as a dependency.
addObserver(Consumer consumer) → void
Registers a consumer to observe changes on this node.
inherited
autoDispose({void onDispose()?}) Signal<AsyncValue<T>>
Configures this signal to automatically dispose when all observers are removed, returning the signal itself to allow fluent builder chaining.
inherited
clearDependencies() → void
Clears all existing registered dependencies and unsubscribes from them.
dispose() → void
Disposes of the resources associated with this signal, executing the onDisposeCallback.
override
invalidate() Future<void>
Invalidates the current operation and immediately starts a new one.
listen(void listener(AsyncValue<T> previous, AsyncValue<T> current), {bool fireImmediately = false}) SignalSubscription<AsyncValue<T>>
Listens to value changes without creating an Effect manually.
inherited
map<R>({required R data(AsyncData<T> data), required R loading(AsyncLoading<T> loading), required R error(AsyncError<T> error)}) → R
maybeMap<R>({R data(AsyncData<T> data)?, R loading(AsyncLoading<T> loading)?, R error(AsyncError<T> error)?, required R orElse()}) → R
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Reloads when a reactive dependency used by the source changes.
notifyObservers() → void
Notifies all registered observers that the value of this node has changed.
inherited
peek() AsyncValue<T>
Returns the current value without registering a reactive dependency.
inherited
refresh() Future<void>
Reloads the source and completes when a Future source settles.
reload() Future<void>
Alias for refresh.
removeChangeListener(void listener(AsyncValue<T> previous, AsyncValue<T> current)) → void
Removes a callback previously registered with addChangeListener.
inherited
removeObserver(Consumer consumer) → void
Unregisters a consumer from observing this node.
inherited
retry() Future<void>
Alias for refresh, useful after an error.
setValueSilently(AsyncValue<T> newValue) → void
Sets the value of this signal without notifying its observers.
inherited
toString() String
A string representation of this object.
inherited
when<R>({required R data(T data), required R loading(), required R error(Object error, StackTrace stackTrace)}) → R
Pattern matching delegated to the current AsyncValue.

Operators

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