when<R> method
R
when<R>({
- required R loading(),
- required R data(
- T data
- required R error(
- BridgeError error
Folds the three states into a single value of type R. Every branch is
required, mirroring the sealed family's exhaustiveness.
Implementation
R when<R>({
required R Function() loading,
required R Function(T data) data,
required R Function(BridgeError error) error,
}) {
return switch (this) {
AsyncLoading<T>() => loading(),
AsyncData<T>(value: final v) => data(v),
AsyncError<T>(error: final e) => error(e),
};
}