Method MapAsync
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
MapAsync<T, TResult>(Maybe<T>, Func<T, Task<TResult>>)
Transforms the contained value with an asynchronous function, if there is one.
public static Task<Maybe<TResult>> MapAsync<T, TResult>(this Maybe<T> a, Func<T, Task<TResult>> f)
Parameters
aMaybe<T>The value to transform.
fFunc<T, Task<TResult>>Run with the contained value when there is one.
Returns
- Task<Maybe<TResult>>
A task giving a Maybe<T> containing the result of
fifacontained a value, and one containing no value otherwise.
Type Parameters
TThe type of the value, when there is one.
TResultThe type of the value the function produces.
Remarks
f is not run when there is no value, thus this is also
how to prevent starting work that has no input.
MapAsync<T, TResult>(Task<Maybe<T>>, Func<T, Task<TResult>>)
Transforms the value the task will give with an asynchronous function, if it gives one.
public static Task<Maybe<TResult>> MapAsync<T, TResult>(this Task<Maybe<T>> a, Func<T, Task<TResult>> f)
Parameters
aTask<Maybe<T>>The task giving the value to transform.
fFunc<T, Task<TResult>>Run with the contained value when there is one.
Returns
- Task<Maybe<TResult>>
A task giving a Maybe<T> containing the result of
fif the awaited value contained one, and one containing no value otherwise.
Type Parameters
TThe type of the value, when there is one.
TResultThe type of the value the function produces.