Created
January 2, 2018 21:47
-
-
Save joanllenas/80974f07b3f65ee5e8f687527b76d5d6 to your computer and use it in GitHub Desktop.
Ejemplo 2 del post "Un sorbo de TEA"
This file contains 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 Counter exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
programParams = | |
{ model = modelo | |
, view = vista | |
, update = actualizar | |
} | |
main = | |
Html.beginnerProgram programParams | |
-- MODEL | |
modelo = | |
{ cont = 0 | |
} | |
-- UPDATE | |
type Msg | |
= Incrementar | |
| Decrementar | |
actualizar mensaje miModelo = | |
case mensaje of | |
Incrementar -> | |
{ miModelo | cont = miModelo.cont + 1 } | |
Decrementar -> | |
{ miModelo | cont = miModelo.cont - 1 } | |
-- VIEW | |
vista miModelo = | |
div [] | |
[ span [ style [ ( "padding", "5px" ) ] ] [ text (toString miModelo.cont) ] | |
, button [ onClick Incrementar ] [ text "+1" ] | |
, button [ onClick Decrementar ] [ text "-1" ] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment