Table of Contents

Method MatchAsync

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

MatchAsync<T>(Func<object?, Task<T>>, Func<Task<T>>)

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

Task<T> MatchAsync<T>(Func<object?, Task<T>> onSome, Func<Task<T>> onNone)

Parameters

onSome Func<object, Task<T>>

Run with the contained value when there is one.

onNone Func<Task<T>>

Run when there is no value.

Returns

Task<T>

The task returned by whichever function was run.

Type Parameters

T

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.