https://github.com/globalwebindex/cmd-extra
Extra functions for working with Cmds
https://github.com/globalwebindex/cmd-extra
elm elm-architecture
Last synced: 8 months ago
JSON representation
Extra functions for working with Cmds
- Host: GitHub
- URL: https://github.com/globalwebindex/cmd-extra
- Owner: GlobalWebIndex
- License: bsd-3-clause
- Created: 2017-04-10T16:59:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-12T02:40:16.000Z (almost 3 years ago)
- Last Synced: 2025-03-24T00:14:30.408Z (about 1 year ago)
- Topics: elm, elm-architecture
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/GlobalWebIndex/cmd-extra/latest/
- Size: 120 KB
- Stars: 7
- Watchers: 35
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Cmd.Extra
Experimental package with helpful functions for working with Cmd.
This package can help you with construction of `Cmd msg` and composition of pair `(model, Cmd msg)` that can be used to streamline your flow of actions in `update`.
```elm
type Msg
= NoOp
| Disarm
| Fire
| FireRockets
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
DoNothing ->
Cmd.Extra.pure model
-- equivalent of (model, Cmd.none)
Disarm ->
Cmd.Extra.withTrigger NoOp model
-- equivalent of (model, Cmd.Extra.perform NoOp)
Fire ->
( model, Cmd.Extra.perform FireRockets )
FireRockets ->
Rockets.Nukes.fire
```
Feedback and contributions are very welcome.
## License
BSD 3-Clause License