ofFunc<Msg, Result> static method
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.
onException
:
Function that returns a message when the function raised an Exception, using the exception as input.
onError
:
Function that returns a message when the function raised an Error, using the error as input.
Implementation
static Cmd<Msg> ofFunc<Msg, Result>(FutureOr<Result?> Function() task,
{Msg Function(Result)? onSuccess,
Msg? onMissing,
Msg Function(Exception)? onException,
Msg Function(Error)? onError}) =>
ofArgFunc((_) => task(), (),
onMissing: onMissing,
onError: onError,
onException: onException,
onSuccess: onSuccess);