summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ElmModule')
-rw-r--r--src/ElmModule/Init.elm4
-rw-r--r--src/ElmModule/Update.elm22
2 files changed, 24 insertions, 2 deletions
diff --git a/src/ElmModule/Init.elm b/src/ElmModule/Init.elm
index 885153a..08c2540 100644
--- a/src/ElmModule/Init.elm
+++ b/src/ElmModule/Init.elm
@@ -5,6 +5,8 @@ import Struct.Flags
import Struct.Event
import Struct.Model
+import Comm.LoadStory
+
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -15,4 +17,4 @@ import Struct.Model
init : Struct.Flags.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
init flags =
-- TODO: read flags and request story.
- ((Struct.Model.new), Cmd.none)
+ ((Struct.Model.new), (Comm.LoadStory.request "/story/0.json"))
diff --git a/src/ElmModule/Update.elm b/src/ElmModule/Update.elm
index 3dbad82..d7617bd 100644
--- a/src/ElmModule/Update.elm
+++ b/src/ElmModule/Update.elm
@@ -1,10 +1,12 @@
module ElmModule.Update exposing (update)
-- Elm -------------------------------------------------------------------------
+import Html
-- Local Module ----------------------------------------------------------------
import Struct.Event
import Struct.Model
+import Struct.UI
import Update.Story
@@ -22,6 +24,24 @@ update : (
)
update event model =
case event of
- Struct.Event.None -> (model, Cmd.none)
(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
+ )