ResTFlatMapAsync(FuncT, TaskRes) Method

(async version) Returns the error when IsErr; map(Unwrap()) when IsOk flattenning the result. Shorthand combining Map and Flatten calls.
C#
static Res<Team> TryGetTeam() { .. } // tries to grab a team; might fail, hence, returns Res.
static Res TryPutTeam(Team team) { .. } // tries to put the team; might fail, hence, returns Res.

Res result = TryGetTeam().FlatMap(TryPutTeam);
// equivalently:
Res result = TryGetTeam().FlatMap(team => TryPutTeam(team));

// this is a shorthand for:
Res result = TryGetTeam()   // Res<Team>
    .Map(TryPutTeam)        // 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> FlatMapAsync(
	Func<T, Task<Res>> map
)

Parameters

map  FuncT, TaskRes
Function (T -> Res) that maps the underlying value to a Res when IsOk.

Return Value

TaskRes

See Also