-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShapeOrColour.elm
44 lines (35 loc) · 893 Bytes
/
ShapeOrColour.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module ShapeOrColour exposing (..)
import Html exposing (program)
import Model exposing (Model, defaultModel, Colouring(..))
import View exposing (view)
import Msg exposing (Msg)
import Update exposing (update)
import Ports
import Window
import Task
init : ( Model, Cmd Msg )
init =
( defaultModel Plain, Task.perform extractWidth Window.size )
extractWidth : Window.Size -> Msg
extractWidth =
.width >> toFloat >> Msg.SetWidth
subscriptions : Model -> Sub Msg
subscriptions =
[ Msg.NewGame Plain
|> always
|> Ports.newPlainGame
, Msg.NewGame Coloured
|> always
|> Ports.newColouredGame
, Window.resizes extractWidth
]
|> Sub.batch
|> always
main : Program Never Model Msg
main =
program
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}