when<R> method

Future<R> when<R>({
  1. required R ok(
    1. T
    ),
  2. required R err(
    1. E
    ),
})

Invokes either ok or err depending on the result.

Identical to match except that the arguments are named.

Implementation

Future<R> when<R>({required R Function(T) ok, required R Function(E) err}) =>
    then((result) => result.when(ok: ok, err: err));