fx-flow v0.7.0 / flow / errThen
Function: errThen()
errThen(fn, result)
errThen<
A
>(fn
,result
):MaybePromise
<Result
<A
>>
Call fn
if result
is failure.
Type parameters
• A
Parameters
• fn
• result: Result
<A
>
Returns
MaybePromise
<Result
<A
>>
Example
typescript
const userInfo = (await errThen(queryUserInfo, err(userId))).unwrap() // throw an error
// with flow
const userInfo = (await flow(ok(userId), andThen(queryUserInfo), errThen(notify))).unwrapOr(defaultUserInfo)
Source
packages/core/src/flow/errThen.ts:18
errThen(fn)
errThen<
A
>(fn
): (result
) =>MaybePromise
<Result
<A
>>
Type parameters
• A
Parameters
• fn
Returns
Function
Parameters
• result: Result
<A
>
Returns
MaybePromise
<Result
<A
>>
Source
packages/core/src/flow/errThen.ts:19
errThen(fn, result)
errThen<
A
>(fn
,result
):Result
<A
>
Type parameters
• A
Parameters
• fn
• result: Result
<A
>
Returns
Result
<A
>
Source
packages/core/src/flow/errThen.ts:20
errThen(fn)
errThen<
A
>(fn
): (result
) =>Result
<A
>
Type parameters
• A
Parameters
• fn
Returns
Function
Parameters
• result: Result
<A
>
Returns
Result
<A
>