AsyncSource<T> class abstract

Abstract interface for async data sources.

AsyncSource defines how to start and manage an asynchronous operation that emits values to an AsyncSignal. Implement this interface to create custom async sources for AsyncSignal.

Example:

class MyAsyncSource<T> extends AsyncSource<T> {
  @override
  FutureOr<void> subscribe(void Function(AsyncState<T> state) emit) async {
    emit(AsyncLoading());
    try {
      final data = await fetchData();
      emit(AsyncSuccess(data));
    } catch (e, st) {
      emit(AsyncError(e, st));
    }
  }
}
Implementers

Constructors

AsyncSource()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() FutureOr<void>
Disposes this async source and cleans up resources.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
subscribe(void emit(AsyncState<T> state)) FutureOr<void>
Subscribes to the async source and emits states.
toString() String
A string representation of this object.
inherited

Operators

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