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
onSomeFunc<object, Task<T>>Run with the contained value when there is one.
onNoneFunc<Task<T>>Run when there is no value.
Returns
- Task<T>
The task returned by whichever function was run.
Type Parameters
TThe 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.