This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
README

Flash

A Flash module

This module provides a mechanism for controlling the events around showing and hiding a flash message.

Types

type State = State (Maybe String)

The State type

Initializing an empty flash message

none : State

An empty State, no flash message

Getting the flash message out

getMessage : State -> Maybe String

Getting the flash message out of the state container

Setting the flash and timer

setFlash : msg -> Time -> String -> ( State, Cmd msg )

Initializing the timer with a flash message

Example:

Flash.setFlash RemoveFlash 2000 "My flash message for 2 seconds"
module Flash
    exposing
        ( State
        , setFlash
        , none
        , getMessage
        )

{-|
A Flash module

This module provides a mechanism for controlling the events around showing and hiding a flash message.

# Types
@docs State

# Initializing an empty flash message
@docs none

# Getting the flash message out
@docs getMessage

# Setting the flash and timer
@docs setFlash

-}

import Process
import Task
import Time exposing (Time)


{-| The State type
-}
type State
    = State (Maybe String)


{-| An empty State, no flash message
-}
none : State
none =
    State Nothing


{-| Getting the flash message out of the state container
-}
getMessage : State -> Maybe String
getMessage (State message) =
    message


{-| Initializing the timer with a flash message

  Example:

    Flash.setFlash RemoveFlash 2000 "My flash message for 2 seconds"
-}
setFlash : msg -> Time -> String -> ( State, Cmd msg )
setFlash msg timeout flashMessage =
    ( State (Just flashMessage), Task.perform (always msg) (Process.sleep timeout) )