ofFunc<Msg, Result> static method
Cmd<Msg>
ofFunc<Msg, Result>(
- FutureOr<
Result?> task(), { - Msg onSuccess(
- Result
- Msg? onMissing,
- Msg onThrow(
- dynamic
Call a function that after returning a result, can be used to create and dispatch a new message.
task:
Function that returns a result that might be turned into a message.
onSuccess:
Function that returns a message when the function terminated successfully using the returned non-null result from the task.
onMissing:
Message used when the function terminated successfully and returned a null value.
onThrow:
Function that returns a message when the function throws anything — covers both Exception and Error subclasses as well as any other thrown object.
Implementation
static Cmd<Msg> ofFunc<Msg, Result>(FutureOr<Result?> Function() task,
{Msg Function(Result)? onSuccess,
Msg? onMissing,
Msg Function(dynamic)? onThrow}) =>
ofArgFunc((_) => task(), (),
onMissing: onMissing, onThrow: onThrow, onSuccess: onSuccess);