Method MatchAsync
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
MatchAsync<T>(Func<object?, Task<T>>, Func<object?, Task<T>>)
Runs one of the two asynchronous functions depending on which case is held, and returns its result.
Task<T> MatchAsync<T>(Func<object?, Task<T>> onFirst, Func<object?, Task<T>> onSecond)
Parameters
onFirstFunc<object, Task<T>>Run with the value when the first case is held.
onSecondFunc<object, Task<T>>Run with the value when the second case is held.
Returns
- Task<T>
The task returned by whichever function was run.
Type Parameters
TThe 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.