Table of Contents

Method MatchAsync

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Task<TResult>>)

Runs one asynchronous function when there is a value, and a different one when there is none, and gives the result.

public Task<TResult> MatchAsync<TResult>(Func<T, Task<TResult>> onSome, Func<Task<TResult>> onNone)

Parameters

onSome Func<T, Task<TResult>>

Run with the contained value when there is one.

onNone Func<Task<TResult>>

Run when there is no value.

Returns

Task<TResult>

The task returned by whichever function was run.

Type Parameters

TResult

The type each of the two functions produces.

Remarks

Only the selected function runs. The task from this call is its task, and not a wrapper. Thus, a failure shows as a fault on that task, and not as an exception from this call.