Skip to content

Latest commit

 

History

History
30 lines (18 loc) · 646 Bytes

File metadata and controls

30 lines (18 loc) · 646 Bytes

AsyncOption.either

Namespace: FsToolkit.ErrorHandling

Function Signature

Provide two functions to execute depending on the value of the option. If the option is Some, the first function will be executed. If the option is None, the second function will be executed.

(onSome : 'T -> Async<'output>) -> (onNone : Async<'output>) -> (input : Async<'T option>) -> Async<'output>

Examples

Example 1

AsyncOption.either (fun x -> async { x * 2 }) (async { 0 }) (AsyncOption.some 5)

// async { 10 }

Example 2

AsyncOption.either (fun x -> x * 2) (async { 0 }) None

// async { 0 }