Table of Contents

Method MatchAsync

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

MatchAsync<T>(Func<T1, Task<T>>, Func<T2, Task<T>>, Func<T3, Task<T>>, Func<T4, Task<T>>)

Runs one of the four asynchronous functions depending on which case is held, and returns its result.

public Task<T> MatchAsync<T>(Func<T1, Task<T>> onFirst, Func<T2, Task<T>> onSecond, Func<T3, Task<T>> onThird, Func<T4, Task<T>> onFourth)

Parameters

onFirst Func<T1, Task<T>>

Run with the value when the first case is held.

onSecond Func<T2, Task<T>>

Run with the value when the second case is held.

onThird Func<T3, Task<T>>

Run with the value when the third case is held.

onFourth Func<T4, Task<T>>

Run with the value when the fourth case is held.

Returns

Task<T>

The task returned by whichever function was run.

Type Parameters

T

The type each of the 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.