withoutPreviousData method

AsyncValue<T> withoutPreviousData()

Fills in the AsyncLoading.previousData or AsyncError.previousData with None so that there is no previous data whatsoever in the AsyncValue. This also means that data will only be Some when this is AsyncData, which can be useful when you want to erase any non-relevant previous data.

Implementation

AsyncValue<T> withoutPreviousData() {
  return switch (this) {
    AsyncData() => this,
    AsyncLoading() => AsyncLoading(None<T>()),
    AsyncError(:final error, :final stackTrace) =>
      AsyncError(error, stackTrace, None<T>()),
  };
}