blob: 081357374b81e391984f2eee385c86131c6e754a (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
module Main
( 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 TransitRouter
import Task exposing (..)
import Time exposing (..)
import Server
import Mailbox
import Action exposing (..)
import Model exposing (Model, initialModel)
import Model.InitResult as InitResult exposing (initResultDecoder)
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 = (initData, Effects.none) `Effects.andThen` initRouter
, view = view
, update = update
, inputs =
[ Signal.map UpdateTime (Time.every 1000)
, Signal.map RouterAction TransitRouter.actions
, Mailbox.signal
]
}
-- Init
initData : Model
initData =
case Json.decodeString initResultDecoder initResult of
Ok init ->
initialModel initialTime translations conf init
Err _ ->
initialModel initialTime translations conf InitResult.InitEmpty
initRouter : Model -> (Model, Effects Action)
initRouter model = TransitRouter.init routerConfig location model
-- Output ports
port tasks : Signal (Task.Task Never ())
port tasks = app.tasks
-- Input ports
port initialTime : Time
port translations : String
port conf : String
port initResult : String
port location : String
|