This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
A library to manage flash message state
version 1.0.3
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.3
Committed At 2017-06-28 00:15:55 UTC
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

Modules

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 ]