This package makes it easier to build (module, Cmd msg), the typical result of an update function
Pack multiple cmds with your model
model
|> withCmds [ cmd0, cmd1 ]Pack your model with no cmd
model
|> withNoCmdPack a model with your cmd. This is useful if the business logic for your command is more complicated than the business logic for your model
Close ->
model.sessionId
|> Ports.Close
|> Ports.send
|> withModel modelSometimes you need to add a cmd to an already packaged model and cmd.
(model, cmd0)
|> addCmd cmd1
-- == (model, Cmd.batch [ cmd1, cmd0 ])Add many cmds to an already packaged model and cmd.
(model, cmd0)
|> addCmds [ cmd1, cmd2 ]
-- == (model, Cmd.batch [ cmd0, cmd1, cmd2 ])If you need to transform just the model in a tuple, such as if you need to pack a submodel into the main model
loginModel
|> Login.update subMsg
|> mapModel (setPage model Page.Login)If you need to transform just the cmd in a tuple, such as if you need to wrap a sub-modules msg type
loginModel
|> Login.update subMsg
|> mapCmd LoginMsgIdeally you wouldnt have to deconstruct a tupled model and cmd, but if you need to, this function does it.
Return2.model (model, cmd) == modelGet the cmd of an already tupled model and cmd.
Return2.cmd (model, cmd) == cmd
Pack a cmd with your model