makeState<T> static method

AsyncState<T> makeState<T>({
  1. required ValueCell<T> current,
})

Implementation

static AsyncState<T> makeState<T>({
  required ValueCell<T> current,
}) {
  final last = (current as ValueCell<T?>)
      .onError(NoneCell())
      .onError(null.cell);

  try {
    return AsyncStateData(current(), last());
  }
  on PendingAsyncValueError {
    return AsyncStateLoading(last());
  }
  catch (e, trace) {
    return AsyncStateError(e, trace, last());
  }
}