Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maorleger/elm-flash
A Flash module
https://github.com/maorleger/elm-flash
Last synced: 27 days ago
JSON representation
A Flash module
- Host: GitHub
- URL: https://github.com/maorleger/elm-flash
- Owner: maorleger
- License: mit
- Created: 2017-06-28T00:09:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-28T00:16:09.000Z (over 7 years ago)
- Last Synced: 2024-12-09T18:01:19.185Z (about 1 month ago)
- Language: HTML
- Size: 26.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-flash
A small library to manage showing and hiding flash messages. The client is in control of the length of time and the view layer. The library simply wraps some state and controls showing and hiding events.
## As an example:
```
-- Initialize our flash message
init =
({
...
flash = Flash.none
...
}, Cmd.none)-- Set flash message for 2 seconds
update =
case msg of
...
SetFlash ->
let
( message, cmd) =
Flash.setFlash RemoveFlash 2000 "My flash message for 2 seconds"
in
({ model | flash = message }, cmd)RemoveFlash ->
({ model | flash = Flash.none }, Cmd.none)
...-- Use it in your view
view =
...
++ case (Flash.getMessage model.flash) of
Nothing ->
[]Just message ->
[ text <| "Flash: " ++ message ]
```