maybeWhen<R> method
R
maybeWhen<R>({
- R notInitialized()?,
- R inProgress(
- CancelableOperation<
T> operation
- CancelableOperation<
- R ready(
- T value
- R failed(
- Object exception
- required R orElse(),
Implementation
R maybeWhen<R>({
R Function()? notInitialized,
R Function(CancelableOperation<T> operation)? inProgress,
R Function(T value)? ready,
R Function(Object exception)? failed,
required R Function() orElse,
}) {
final value = this;
if (value is ComputedStateValueNotInitialized && notInitialized != null) return notInitialized();
if (value is ComputedStateValueInProgress<T> && inProgress != null) {
return inProgress(value.operation);
}
if (value is ComputedStateValueReady<T> && ready != null) return ready(value.value);
if (value is ComputedStateValueFailed && failed != null) return failed(value.exception);
return orElse();
}