ofFunc<Msg, Result> static method

Cmd<Msg> ofFunc<Msg, Result>(
  1. FutureOr<Result?> task(), {
  2. Msg onSuccess(
    1. Result
    )?,
  3. Msg? onMissing,
  4. Msg onException(
    1. Exception
    )?,
  5. Msg onError(
    1. Error
    )?,
})

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);