A Signal holding the AsyncValue of an asynchronous operation.
The signal starts AsyncIdle. run executes a fetcher and publishes AsyncLoading, then AsyncData or AsyncError, with latest-wins semantics: starting a new run drops the outcome of any older one still in flight. While a run is in flight the state carries the previous data, so UIs can keep showing it.
final AsyncSignal<int> total = AsyncSignal();
await total.run(() async => 42);
print(total.value); // AsyncData<int>(42)
Tracking stays fully synchronous: the fetcher runs outside the reactive graph and writes its outcome back into the signal.
See also:
- AsyncValue, the four states a run publishes.
- ReadonlySignalSubscriptions.when, to await a state from outside the widget tree.
- Inheritance
-
- Object
- ChangeNotifier
- Signal<
AsyncValue< T> > - AsyncSignal
Constructors
- AsyncSignal()
- Creates the signal in the AsyncIdle state.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
value
↔ AsyncValue<
T> -
The current value of the object.
getter/setter pairinherited
Methods
-
addDependent(
ReactiveNode dependent) → void -
Registers
dependentto be marked stale when this source changes.inherited -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
peek(
) → AsyncValue< T> -
Reads the current value without registering a dependency.
inherited
-
removeDependent(
ReactiveNode dependent) → void -
Stops cascading staleness to
dependent.inherited -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
run(
Future< T> fetcher()) → Future<void> -
Runs
fetcherand publishes loading, then data or error. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
AsyncValue< T> transform(AsyncValue<T> current)) → void -
Derives the next value from the current one and writes it.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited