batchMap : List (a -> Platform.Cmd.Cmd msg) -> a -> Platform.Cmd.Cmd msg
Batches the commands returned by the given functions
fetchUsers : Model -> Cmd Msg
serializeData : Model -> Cmd Msg
model
|> batchMap [ fetchUsers, serializeData ]
cmdMap : List (a -> Platform.Cmd.Cmd msg) -> a -> List (Platform.Cmd.Cmd msg)
Maps the given Cmd suppliers to the same value. Usually used like that:
fetchUsers : Model -> Cmd Msg
sendLog : Model -> Cmd Msg
initializeAnalytics : Model -> Cmd Msg
model
|> cmdMap
[ fetchUsers
, sendLog
, initializeAnalytics
]
fromMaybeMap : (a -> Platform.Cmd.Cmd msg) -> Maybe a -> Platform.Cmd.Cmd msg
Returns Cmd.none
when argument is Nothing, maps it otherwise
fromMaybeMap Ports.log Nothing -- => Cmd.none
fromMaybeMap Ports.log (Just "hello!") -- => Ports.log "hello!"
ifThenCmd : Basics.Bool -> Platform.Cmd.Cmd msg -> Platform.Cmd.Cmd msg
ifThenCmd True x -- => x
ifThenCmd False x -- => Cmd.none
ifThenCmdMap : (a -> Basics.Bool) -> (a -> Platform.Cmd.Cmd msg) -> a -> Platform.Cmd.Cmd msg
fetchUsers : Model -> Cmd Msg
model
|> ifThenCmdMap Model.usersAreNotPresent
fetchUsers
ifThenCmds : Basics.Bool -> List (Platform.Cmd.Cmd msg) -> Platform.Cmd.Cmd msg
ifThenCmd True cmds -- => Cmd.batch cmds
ifThenCmd False x -- => Cmd.none
ifThenCmdsMap : (a -> Basics.Bool) -> List (a -> Platform.Cmd.Cmd msg) -> a -> Platform.Cmd.Cmd msg
Like ifThenCmdMap
, but with a list of cmds
fetchUsers : Model -> Cmd Msg
serializeData : Model -> Cmd Msg
model
|> ifThenCmdsMap Model.usersAreNotPresent
[ fetchUsers
, serializeData
]
ifThenElseCmdMap : (a -> Basics.Bool) -> (a -> Platform.Cmd.Cmd msg) -> (a -> Platform.Cmd.Cmd msg) -> a -> Platform.Cmd.Cmd msg
Same as PrimaFunction.ifThenElseMap
but for Cmds
model
|> ifThenElseMap modelHasError
(Model.toError >> Ports.logError)
(always () >> Ports.logSuccess)
ifThenElseCmdsMap : (a -> Basics.Bool) -> List (a -> Platform.Cmd.Cmd msg) -> List (a -> Platform.Cmd.Cmd msg) -> a -> Platform.Cmd.Cmd msg
Like ifThenCmdMap
, but for List of commands
model
|> ifThenElseMap modelHasError
[ Model.toError >> Ports.logError ]
[ always () >> Ports.logSuccess
, Ports.serializeModel
]
ifThenElseCmds : Basics.Bool -> List (Platform.Cmd.Cmd msg) -> List (Platform.Cmd.Cmd msg) -> Platform.Cmd.Cmd msg
Like ifThenElse
, but batches Cmds
ifThenElseMap model.hasError
[ Ports.logError () ]
[ Ports.logSuccess () ]
fromMsgWithDelay : Basics.Int -> msg -> Platform.Cmd.Cmd msg
Create a Cmd that triggers the given msg after n milliseconds
fromMsg : msg -> Platform.Cmd.Cmd msg
Lifts a msg to a Cmd.
warning: this is usually an antipattern.
There are specific case in which this can be used (such as flip animations) but unless you encountered such edge cases, be sure to double check if there are different approaches possible