type alias Model =
{ alerts : Alert.State }
type Msg
= ShowAlert
| AlertMsg Alert.Msg
view : Model -> Html Msg
view model =
div []
[ button [ onClick ShowAlert, class "btn btn-success" ] [ text "Hit me!" ]
, Html.map AlertMsg (Alert.view model.alerts)
]
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
ShowAlert ->
let
( alerts, cmd ) =
Alert.success "Hello, nice to meet you!" model.alerts
in
{ model | alerts = alerts } ! [ Cmd.map AlertMsg cmd ]
AlertMsg subMsg ->
let
( alerts, cmd ) =
Alert.update subMsg model.alerts
in
{ model | alerts = alerts } ! [ Cmd.map AlertMsg cmd ]
main : Program Never Model Msg
main =
Html.program
{ init = { alerts = Alert.initState } ! []
, view = view
, update = update
, subscriptions = always Sub.none
}
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
License
PaackEng/elm-alert-beta
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published