module App exposing (..)

import Html exposing (Html, button, div, program, text)
import Html.Events exposing (onClick)


-- MODEL


type alias Model =
    Int


init : ( Model, Cmd Msg )
init =
    ( 0, Cmd.none )



-- MESSAGES


type Msg
    = Increment Int
    | Decrement Int



-- VIEW


view : Model -> Html Msg
view model =
    div []
        [ button [ onClick (Increment 10) ] [ text "+10" ]
        , div [] [ text (toString model) ]
        , button [ onClick (Decrement 10) ] [ text "-10" ]
        ]


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        Increment n ->
            ( model + n, Cmd.none )

        Decrement n ->
            ( model - n, Cmd.none )


subscriptions : model -> Sub Msg
subscriptions model =
    Sub.none


main : Program Never Model Msg
main =
    program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

module Main exposing (..)

import Html exposing (Html, div, program, text)
import Mouse
import Keyboard


-- MODEL


type alias Model =
    Int


init : ( Model, Cmd Msg )
init =
    ( 0, Cmd.none )



-- MESSAGES


type Msg
    = MouseMsg Mouse.Position
    | KeyMsg Keyboard.KeyCode



-- VIEW


view : Model -> Html Msg
view model =
    div [] [ text (toString model) ]


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        MouseMsg positionMouse ->
            ( model + 1, Cmd.none )

        KeyMsg keyCodeKeyboard ->
            ( model + 2, Cmd.none )


subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.batch
        [ Mouse.downs MouseMsg
        , Keyboard.ups KeyMsg
        ]


main : Program Never Model Msg
main =
    program
        { init = init
        , view = view
        , update = update
        , subscriptions = subscriptions
        }

Add my first subscriptions app
:+1: Add my first subscriptions app
