when<R> method

R when<R>({
  1. required R notInitialized(),
  2. required R inProgress(
    1. CancelableOperation<T> operation
    ),
  3. required R ready(
    1. T value
    ),
  4. required R failed(
    1. Object exception
    ),
})

Implementation

R when<R>({
  required R Function() notInitialized,
  required R Function(CancelableOperation<T> operation) inProgress,
  required R Function(T value) ready,
  required R Function(Object exception) failed,
}) {
  return maybeWhen(
    notInitialized: notInitialized,
    inProgress: inProgress,
    ready: ready,
    failed: failed,
    orElse: () {
      throw StateError('Invalid ComputedStateValue descendant');
    },
  );
}