flatMapFirst<A> function

TaskOption<A> Function(TaskOption<A> taskOption) flatMapFirst<A>(
  1. TaskOption f(
    1. A value
    )
)

Similar to flatMap, except Some values are discarded.

expect( await some(123).chain(flatMapFirst((i) => some('got: $i')))(), O.some(123), ); expect( await some(123).chain(flatMapFirst((i) => none()))(), O.none(), );

Implementation

TaskOption<A> Function(TaskOption<A> taskOption) flatMapFirst<A>(
  TaskOption<dynamic> Function(A value) f,
) =>
    flatMap((r) => f(r).chain(map((_) => r)));