Cmd<Model> class
Class that implements some helpers when creating commands. Commands are a list of Sub
Constructors
-
Cmd(List<
Sub< base)Model> > -
const
- Cmd.none()
-
Creates an empty Cmd
const
- Cmd.ofFunctionModel(Model msg(Model model), {bool doRebuild = true})
- Creates a new Cmd from a function returning Model
-
Cmd.ofFunctionUpdate(Update<
Model> msg(Model model)) - Creates a new Cmd from a function returning Update
-
Cmd.ofSub(Sub<
Model> sub) - Creates a new Cmd from a Sub
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
batch<
Model> (List< Cmd< cmds) → Cmd<Model> >Model> - Takes a list of Cmds and flat them to a single Cmd
-
fmap<
TModel, Model> (TModel innerModel(Model model), Model merge(Model model, TModel innerModel), Cmd< TModel> cmd) → Cmd<Model> - Takes a mapping function from the root model to the inner model, a merge function to update the root model and a list of inner commands, transforming the inner commands to compatible commands
-
ofAction<
Model> (FutureOr< void> action(), {Update<Model> onSuccessUpdate(Model model)?, Model onSuccessModel(Model model)?, Cmd<Model> ? onSuccessCommands, Update<Model> onErrorUpdate(Model model, Exception e)?, Model onErrorModel(Model model, Exception e)?, Cmd<Model> onErrorCommands(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Do some action. Optionally dispatch a message if the action was successful and dispatch a message on case of Exception
-
ofAsyncValue<
Model> (Future action, {Update< Model> onSuccessUpdate(Model model)?, Model onSuccessModel(Model model)?, Cmd<Model> ? onSuccessCommands, Update<Model> onErrorUpdate(Model model, Exception e)?, Model onErrorModel(Model model, Exception e)?, Cmd<Model> onErrorCommands(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Do some async action. Optionally dispatch a message if the action was successful and dispatch a message on case of Exception
-
ofCancelableModelMsg<
Model> ({required Model Function(Model) cancellableMsg(void cancel()), required Future< Model Function(Model)> onComplete, required Model onCancel(Model), bool doRebuild = true}) → Cmd<Model> - Creates a cancelable message from a future message that can send a different message when cancelled
-
ofCancelableMsg<
Model> ({required BehaviorMsg< Model> cancellableMsg(void cancel()), required Future<BehaviorMsg< onComplete, required BehaviorMsg<Model> >Model> onCancel}) → Cmd<Model> - Creates a cancelable message from a future message that can send a different message when cancelled
-
ofFunc<
Result, Model> (FutureOr< Result> func(), {Update<Model> onSuccessUpdate(Model model, Result r)?, Model onSuccessModel(Model model, Result r)?, Cmd<Model> onSuccessCommands(Result r)?, Update<Model> onErrorUpdate(Model model, Exception e)?, Model onErrorModel(Model model, Exception e)?, Cmd<Model> onErrorCommands(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Perform a function. Takes a mapping function to map the result to a Msg. Optionally takes a function to dispatch a message on Exception.
-
ofModelAction<
Model> (FutureOr< void> action(Model model), {Update<Model> onSuccessUpdate(Model model)?, Model onSuccessModel(Model model)?, Cmd<Model> ? onSuccessCommands, Update<Model> onErrorUpdate(Model model, Exception e)?, Model onErrorModel(Model model, Exception e)?, Cmd<Model> onErrorCommands(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Do some action receiving the current model. Optionally dispatch a message if the action was successful and dispatch a message on case of Exception
-
ofModelFunc<
Result, Model> (FutureOr< Result> func(Model model), {Update<Model> onSuccessUpdate(Model model, Result r)?, Cmd<Model> onSuccessCommands(Result r)?, Model onSuccessModel(Model model, Result r)?, Update<Model> onErrorUpdate(Model model, Exception e)?, Model onErrorModel(Model model, Exception e)?, Cmd<Model> onErrorCommands(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Perform a function receiving the current model. Takes a mapping function to map the result to a Msg. Optionally takes a function to dispatch a message on Exception.
-
ofModelMsg<
Model> (FutureOr< Model Function(Model)> asyncMsg, {BehaviorMsg<Model> onError(Exception e)?, bool doRebuild = true}) → Cmd<Model> - Takes an async model Msg. Optionally takes a function to dispatch a message if awaiting the Msg fails
-
ofMsg<
Model> (FutureOr< BehaviorMsg< asyncMsg, {BehaviorMsg<Model> >Model> onError(Exception e)?}) → Cmd<Model> - Takes a Msg. Optionally takes a function to dispatch a message if awaiting the Msg fails