Skip to content

fx-flow v0.7.0 / flow / andThen

Function: andThen()

andThen(fn, result)

andThen<A, R>(fn, result): ResultReturnValue<R>

Call fn if result is success.

Type parameters

A

R extends MaybePromise<Result<unknown>>

Parameters

fn

result: Result<A>

Returns

ResultReturnValue<R>

Example

typescript
const userInfo = (await andThen(queryUserInfo, ok(userId))).unwrap()
// with flow
const userInfo = (await flow(ok(userId), andThen(queryUserInfo))).unwrap()

More examples

Source

packages/core/src/flow/andThen.ts:18

andThen(fn)

andThen<A, R>(fn): (result) => ResultReturnValue<R>

Type parameters

A

R extends MaybePromise<Result<unknown>>

Parameters

fn

Returns

Function

Parameters

result: Result<A>

Returns

ResultReturnValue<R>

Source

packages/core/src/flow/andThen.ts:22

Released under the MIT License.