unwrapPrevious method

AsyncValue<T> unwrapPrevious()

The opposite of copyWithPrevious, reverting to the raw AsyncValue with no information on the previous state.

Implementation

AsyncValue<T> unwrapPrevious() {
  return map(
    data: (d) {
      if (d.isLoading) return AsyncLoading<T>();
      return AsyncData(d.value);
    },
    error: (e) {
      if (e.isLoading) return AsyncLoading<T>();
      return AsyncError(e.error, e.stackTrace);
    },
    loading: (l) => AsyncLoading<T>(),
  );
}