chainTryCatchK<A, B> function

TaskOption<B> Function(TaskOption<A> taskOption) chainTryCatchK<A, B>(
  1. FutureOr<B> task(
    1. A value
    )
)

A chainable variant of tryCatchK, that unwraps the given TaskOption.

final catcher = chainTryCatchK((int i) => i > 5 ? i : throw 'too small!');

expect(
  await some(10).chain(catcher)(),
  O.some(10),
);
expect(
  await some(3).chain(catcher)(),
  O.none(),
);

Implementation

TaskOption<B> Function(TaskOption<A> taskOption) chainTryCatchK<A, B>(
  FutureOr<B> Function(A value) task,
) =>
    flatMap(tryCatchK(task));