ResTFlatMapAsyncTOut(FuncT, TaskResTOut) Method

(async version) Returns None when IsNone; map(val) when IsOk flattening the result. Shorthand combining Map and Flatten calls.
C#
static Res<User> TryGetUser() {
    // method that tries to get the user, return Ok(user) or Err.
}
static Res< double> TryGetBalance(User user) {
    // method that tries to get usedr's balance; which might fail, returns:
    // Ok(balance) or Err
}
Res<double> balance = TryGetUser().FlatMap(TryGetBalance);
// equivalent to both below:
var balance = TryGetUser().FlatMap(user => TryGetBalance(user));
var balance = TryGetUser()              // Res<User>
    .Map(user => TryGetBalance(user))   // Res<Res>
    .Flatten();                         // Res

Definition

Namespace: Orx.Fun.Result
Assembly: Orx.Fun.Result (in Orx.Fun.Result.dll) Version: 1.3.0+344c8bdd6f720ccfb2d8db7c61b76cf02be18f5f
C#
public Task<Res<TOut>> FlatMapAsync<TOut>(
	Func<T, Task<Res<TOut>>> map
)

Parameters

map  FuncT, TaskResTOut
Function (T -> Res<TOut>) mapping the underlying value to result of TOut if this.IsOk.

Type Parameters

TOut

[Missing <typeparam name="TOut"/> documentation for "M:Orx.Fun.Result.Res`1.FlatMapAsync``1(System.Func{`0,System.Threading.Tasks.Task{Orx.Fun.Result.Res{``0}}})"]

Return Value

TaskResTOut

See Also