This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init : ( Model, Cmd Msg ) | |
| init = | |
| ( { author = "Adam", quote = "Elm is a nice language to use!" }, Cmd.none ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| subscriptions : Model -> Sub Msg | |
| subscriptions model = | |
| Sub.none |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main : Program Never Model Msg | |
| main = | |
| Html.program | |
| { init = init | |
| , update = update | |
| , subscriptions = subscriptions | |
| , view = view | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| view: Model -> Html Msg | |
| view model = | |
| div [] | |
| [ div [] [ text model.author ] | |
| , div [] [ text model.quote ] | |
| , button [ onClick FetchQuote ] [ text "Fetch new quote" ] | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| update : Msg -> Model -> ( Model, Cmd Msg ) | |
| update msg model = | |
| case msg of | |
| FetchQuote -> | |
| ( model, Random.generate NewQuote (Random.int 0 3) ) | |
| NewQuote index -> | |
| ( withDefault defaultQuote (getAt index quotes), Cmd.none ) | |
| NoOp -> | |
| ( model, Cmd.none ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Msg | |
| = NoOp | |
| | FetchQuote | |
| | NewQuote Int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quotes : List Model | |
| quotes = | |
| [ { author = "Victoria Justice", quote = "It's nice to just embrace the natural beauty within you." } | |
| , { author = "Moises Arias", quote = "It is nice finding that place where you can just go and relax." } | |
| , { author = "Yogi Berra", quote = "It ain't over till it's over" } | |
| , { author = "Albert Einstein", quote = "Look deep into nature, and then you will understand everything better." } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main exposing (..) | |
| import Html exposing (Html, text, div) | |
| -- MODEL | |
| type alias Model = | |
| { author : String | |
| , quote : String | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main : Program Never Model Msg | |
| main = | |
| Html.beginnerProgram | |
| { model = model | |
| , update = update | |
| , view = view | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Msg | |
| = NoOp | |
| update : Msg -> Model -> Model | |
| update msg model = | |
| case msg of | |
| NoOp -> | |
| model |