Skip to content

Instantly share code, notes, and snippets.

@alexesDev
Last active January 14, 2020 11:21
Show Gist options
  • Save alexesDev/7f1db3653ca02791ddd8cbd28fe68b11 to your computer and use it in GitHub Desktop.
Save alexesDev/7f1db3653ca02791ddd8cbd28fe68b11 to your computer and use it in GitHub Desktop.
module Main exposing (..)
import Browser
import Html exposing (Html, button, div, text)
import Html.Events exposing (onClick)
import Random
main : Program () Model Msg
main =
Browser.element { init = \_ -> init, update = update, view = view, subscriptions = \_ -> Sub.none }
type alias Model = Int
init : (Model, Cmd Msg)
init =
(0, Cmd.none)
type Msg
= RunTask (Cmd Msg)
| Update Int
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
RunTask cmd ->
(model, cmd)
Update v ->
(v, Cmd.none)
view : Model -> Html Msg
view model =
let gen from to = RunTask <| Random.generate Update <| Random.int from to
in
div []
[ button [ onClick <| gen -10 10 ] [ text "gen small" ]
, button [ onClick <| gen -1000 1000 ] [ text "gen big" ]
, div [] [ text (String.fromInt model) ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment