-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.elm
74 lines (61 loc) · 2.02 KB
/
App.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module Main exposing (..)
import Html exposing (Html)
import Html.App
import Widget
import Widget2
import Board
-- MODEL
type alias AppModel = { widgetModel : Widget.Model
, widgetModel2 : Widget2.Model
, boardModel : Board.Model }
initialModel : AppModel
initialModel = { widgetModel = Widget.initialModel
, widgetModel2 = Widget2.initialModel
, boardModel = Board.initialModel }
init : ( AppModel, Cmd Msg )
init = ( initialModel, Cmd.none )
-- MESSAGES
type Msg = WidgetMsg Widget.Msg | WidgetMsg2 Widget2.Msg | BoardMsg Board.Msg
-- VIEW
view : AppModel -> Html Msg
view model =
Html.div []
[ Html.App.map WidgetMsg (Widget.view model.widgetModel)
, Html.App.map WidgetMsg2 (Widget2.view model.widgetModel2)
, Html.App.map BoardMsg (Board.view model.boardModel)
]
-- UPDATE
update : Msg -> AppModel -> ( AppModel, Cmd Msg )
update message model =
case message of
WidgetMsg subMsg ->
let
( updatedWidgetModel, widgetCmd ) =
Widget.update subMsg model.widgetModel
in
( { model | widgetModel = updatedWidgetModel }, Cmd.map WidgetMsg widgetCmd )
WidgetMsg2 subMsg2 ->
let
( updatedWidgetModel, widgetCmd ) =
Widget2.update subMsg2 model.widgetModel2
in
( { model | widgetModel2 = updatedWidgetModel }, Cmd.map WidgetMsg2 widgetCmd )
BoardMsg bMsg ->
-- (model, Cmd.none)
let
( updatedBoardModel, bCmd ) =
Board.update bMsg model.boardModel
in
( { model | boardModel = updatedBoardModel }, Cmd.map BoardMsg bCmd )
-- SUBSCIPTIONS
subscriptions : AppModel -> Sub Msg
subscriptions model = Sub.none
-- APP
main : Program Never
main =
Html.App.program
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}