ResFlatMapAsyncTOut(FuncTaskResTOut) Method

(async version) Returns the error when IsErr; map() when IsOk, flattenning the result. This is a shorthand for sequential Map and Flatten calls.
C#
// assume we have two methods that can fail; hence returns a Res:
static Res TryRunRiskyOperation() { .. }
static Res<int> TryGetCount() { .. }

// we want to call both operations; but the second one only if the first one succeeds.
Res result = TryRunRiskyOperation().FlatMap(TryGetCount);
// alternatively:
Res result = TryRunRiskyOperation().FlatMap(() => TryGetCount());

// this is equivalent to:
Res result = TryRunRiskyOperation().Map(() => TryGetCount()/*Res<Res<int>>*/).Flatten()/*Res<int>*/;

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<Task<Res<TOut>>> map
)

Parameters

map  FuncTaskResTOut
Map function to be called lazily to get the final result only if this IsOk.

Type Parameters

TOut

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

Return Value

TaskResTOut

See Also