flatMap<A, B> function
Transform the given TaskOption into a new TaskOption, if it resolves to a Some value.
expect(
await some(123).chain(flatMap((i) => some('got: $i')))(),
O.some('got: 123'),
);
// Transform into a [None] [TaskOption].
expect(
await some(123).chain(flatMap((i) => none()))(),
O.none(),
);
// Does nothing for [None] values.
expect(
await none().chain(flatMap((i) => some('got: $i')))(),
O.none(),
);
Implementation
TaskOption<B> Function(TaskOption<A> taskOption) flatMap<A, B>(
TaskOption<B> Function(A value) f,
) =>
(t) => TaskOption(t.p(T.flatMap(O.fold(() => none<B>(), f))));