toBloomTuple method

({Bloom<T> data, Bloom<bool> pending}) toBloomTuple({
  1. T initialFactory()?,
  2. T onError(
    1. Object error, [
    2. StackTrace? stackTrace
    ])?,
})

Converts this Future into a pair of reactive nodes: ({Bloom<T> data, Bloom<bool> pending}).

  • initialFactory: Optional factory callback returning the initial value before the future completes.
  • onError: Optional error interceptor converting an error into a valid fallback data instance.

Ensures:

  • Returns a Dart 3 named record ({Bloom<T> data, Bloom<bool> pending}) where:
    • data reflects the future's completion value or error state.
    • pending is true while the future is unresolved, and transitions synchronously to false upon settling.

Examples

final (:data, :pending) = fetchUser().toBloomTuple();
// or with custom variable names:
final (data: userBloom, pending: isPendingBloom) = fetchUser().toBloomTuple();

Implementation

@pragma('vm:prefer-inline')
({Bloom<T> data, Bloom<bool> pending}) toBloomTuple({
  T Function()? initialFactory,
  T Function(Object error, [StackTrace? stackTrace])? onError,
}) =>
    _FutureBloomBridge<T>(
      this,
      initialFactory: initialFactory,
      onError: onError,
    ).tuple;