AsyncSignal<T> class abstract interface

Interface for reactive signals that manage async state transitions.

AsyncSignal wraps an AsyncSource and provides a reactive interface to async operations, automatically managing state transitions and providing convenient access to the current async state.

Example:

AsyncSignal<String> signal = AsyncSignal.fromFuture(
  Future.delayed(Duration(seconds: 1), () => 'Hello')
);

Effect(() {
  if (signal.value.isSuccess) {
    print('Data: ${signal.data}');
  }
});
Implemented types

Constructors

AsyncSignal({AsyncSource<T>? source, AsyncState<T>? initialValue, JoltDebugOption? debug})
Creates an async signal with the given source.
factory
AsyncSignal.fromFuture(Future<T> future, {JoltDebugOption? debug})
Creates an async signal from a Future.
factory
AsyncSignal.fromStream(Stream<T> stream, {JoltDebugOption? debug})
Creates an async signal from a Stream.
factory

Properties

data → T?
Gets the data from the current async state.
no setter
error Object?
The error from the current async state, if any.
no setter
hashCode int
The hash code for this object.
no setterinherited
isDisposed bool
Whether this node has been disposed.
no setterinherited
isError bool
Whether the current state represents an error.
no setter
isLoading bool
Whether the current state represents a loading operation.
no setter
isSuccess bool
Whether the current state represents a successful operation with data.
no setter
peek AsyncState<T>
Gets the current value without establishing a reactive dependency.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stackTrace StackTrace?
The stack trace from the current async error state, if any.
no setter
value AsyncState<T>
Gets the current value and establishes a reactive dependency.
getter/setter pairinherited

Methods

dispose() → void
Disposes this node and cleans up resources.
inherited
fetch(AsyncSource<T> source) Future<void>
Replaces the current async source and subscribes to the new one.
map<R>({R loading()?, R success(T)?, R error(Object?, StackTrace?)?}) → R?
Maps the current async state to a value based on its state variant.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify([bool force]) → void
Triggers a change notification without modifying the value.
inherited
toString() String
A string representation of this object.
inherited

Operators

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