AsyncSignal<T>.fromFuture constructor

AsyncSignal<T>.fromFuture(
  1. Future<T> futureFn(), {
  2. String? name,
  3. bool autoDispose = false,
  4. void onDispose()?,
  5. FutureOr<void> onCancel()?,
})

Creates an AsyncSignal from a Future factory.

Dart Futures are not intrinsically cancellable. Use onCancel to cancel the underlying HTTP request, isolate task, or other operation when this signal reloads or is disposed.

Implementation

AsyncSignal.fromFuture(
  Future<T> Function() futureFn, {
  String? name,
  bool autoDispose = false,
  void Function()? onDispose,
  FutureOr<void> Function()? onCancel,
})  : _futureFactory = futureFn,
      _streamFactory = null,
      _onCancel = onCancel,
      super(
        const AsyncLoading(),
        name: name,
        autoDispose: autoDispose,
        onDispose: onDispose,
      ) {
  _initialize();
}