aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Main.elm
diff options
context:
space:
mode:
authorJoris2016-03-28 17:51:14 +0200
committerJoris2016-03-28 17:51:14 +0200
commit166cd04e4b28770ede854dafc9ae30eae64102fe (patch)
tree2245a31243a165acc6f7355534da44cfd17e6038 /src/client/elm/Main.elm
parentb0d80a5458d7ba4546e5f01f5b6398ea6d23f981 (diff)
downloadbudget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.gz
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.tar.bz2
budget-166cd04e4b28770ede854dafc9ae30eae64102fe.zip
Create an empty but reachable user page
Diffstat (limited to 'src/client/elm/Main.elm')
-rw-r--r--src/client/elm/Main.elm48
1 files changed, 32 insertions, 16 deletions
diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm
index 0ba25b7..ac70202 100644
--- a/src/client/elm/Main.elm
+++ b/src/client/elm/Main.elm
@@ -3,11 +3,12 @@ module Main
) where
import Graphics.Element exposing (..)
+import Json.Decode as Json
import Html exposing (Html)
import StartApp exposing (App)
import Effects exposing (Effects, Never)
-import Json.Decode as Json
+import TransitRouter
import Task exposing (..)
import Time exposing (..)
@@ -16,34 +17,48 @@ import Server
import Action exposing (..)
import Model exposing (Model, initialModel)
-import Update exposing (update)
+import Update exposing (update, routerConfig)
import View exposing (view)
import Utils.Maybe exposing (isJust)
+import Utils.Effects as Effects
main : Signal Html
main = app.html
app : App Model
app = StartApp.start
- { init =
- case Json.decodeString Json.string signInError of
- Ok signInError ->
- ( initialModel initialTime translations conf (Just signInError)
- , Effects.none
- )
- Err _ ->
- ( initialModel initialTime translations conf Nothing
- , Server.init
- |> Task.map GoLoggedInView
- |> flip Task.onError (always <| Task.succeed GoSignInView)
- |> Effects.task
- )
+ { init = initData `Effects.andThen` initRouter
, view = view
, update = update
- , inputs = [ Signal.map UpdateTime (Time.every 1000) ]
+ , inputs =
+ [ Signal.map UpdateTime (Time.every 1000)
+ , Signal.map RouterAction TransitRouter.actions
+ ]
}
+-- Init
+
+initData : (Model, Effects Action)
+initData =
+ case Json.decodeString Json.string signInError of
+ Ok signInError ->
+ ( initialModel initialTime translations conf (Just signInError)
+ , Effects.none
+ )
+ Err _ ->
+ ( initialModel initialTime translations conf Nothing
+ , Server.init
+ |> Task.map GoLoggedInView
+ |> flip Task.onError (always <| Task.succeed GoSignInView)
+ |> Effects.task
+ )
+
+initRouter : Model -> (Model, Effects Action)
+initRouter model = TransitRouter.init routerConfig location model
+
+-- Output ports
+
port tasks : Signal (Task.Task Never ())
port tasks = app.tasks
@@ -53,3 +68,4 @@ port initialTime : Time
port translations : String
port conf : String
port signInError : String
+port location : String