blob: d7617bd1ee595677f14a20f72dbe34beaa06cf23 (
plain)
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
|
module ElmModule.Update exposing (update)
-- Elm -------------------------------------------------------------------------
import Html
-- Local Module ----------------------------------------------------------------
import Struct.Event
import Struct.Model
import Struct.UI
import Update.Story
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
update : (
Struct.Event.Type ->
Struct.Model.Type ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
update event model =
case event of
(Struct.Event.ChoiceSelected ix) ->
((Update.Story.select_choice ix model), Cmd.none)
Struct.Event.None -> (model, Cmd.none)
(Struct.Event.LoadStory http_result) ->
case http_result of
(Ok story) ->
((Update.Story.start {model | tonkadur = story}), Cmd.none)
(Err error) ->
(
{model |
ui =
-- TODO: display the actual error.
(Struct.UI.display_error
(Html.text "Failed to load story")
model.ui
)
},
Cmd.none
)
|