diff options
author | Joris | 2016-01-02 19:07:19 +0100 |
---|---|---|
committer | Joris | 2016-01-02 19:07:19 +0100 |
commit | bb316286b0859b5648c61f44c88399f4c1aad9cd (patch) | |
tree | ecbe401c1ff657987b6609997a69775969a317f7 /src/client/elm/Main.elm | |
parent | 0d0c99fd28b782c7daf02fb5cc48d3eb252e705d (diff) |
Use start-app for elm
Diffstat (limited to 'src/client/elm/Main.elm')
-rw-r--r-- | src/client/elm/Main.elm | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/src/client/elm/Main.elm b/src/client/elm/Main.elm index f79d6a0..2f4acb6 100644 --- a/src/client/elm/Main.elm +++ b/src/client/elm/Main.elm @@ -5,85 +5,52 @@ module Main import Graphics.Element exposing (..) import Html exposing (Html) +import StartApp exposing (App) +import Effects exposing (Effects, Never) -import Http import Task exposing (..) import Time exposing (..) -import Json.Decode as Json -import Dict -import String import Model exposing (Model, initialModel) -import Model.Translations exposing (..) -import Model.Config exposing (..) +import Model.Action exposing (..) +import Model.Communication exposing (Communication(SignIn)) -import Update exposing (Action(..), actions, updateModel) -import Update.SignIn exposing (..) +import Update exposing (update) -import View.Page exposing (renderPage) - -import ServerCommunication as SC exposing (serverCommunications, sendRequest) +import View exposing (view) import Persona as Persona exposing (operations) import InitViewAction exposing (initViewAction) -import Sign - main : Signal Html -main = Signal.map renderPage model - -model : Signal Model -model = Signal.foldp updateModel (initialModel initialTime translations config) update - -update : Signal Action -update = Signal.mergeMany - [ Signal.map UpdateTime (Time.every 1000) - , actions.signal - ] - ---------------------------------------- +main = app.html + +app : App Model +app = StartApp.start + { init = + ( initialModel initialTime translations config + , Effects.task initViewAction + ) + , view = view + , update = update + , inputs = + [ Signal.map UpdateTime (Time.every 1000) + , Signal.map (ServerCommunication << SignIn) validateSignIn + ] + } + +port tasks : Signal (Task.Task Never ()) +port tasks = app.tasks + +-- Input ports port initialTime : Time - ---------------------------------------- - port translations : String - ---------------------------------------- - port config : String +port validateSignIn : Signal String ---------------------------------------- - -port ready : Signal String -port ready = Signal.constant "ready" - ---------------------------------------- - -port initView : Task Http.Error () -port initView = initViewAction `Task.andThen` (Signal.send actions.address) - ---------------------------------------- - -port serverCommunicationsPort : Signal (Task Http.Error ()) -port serverCommunicationsPort = - Signal.map - (\comm -> - sendRequest comm - |> flip Task.andThen (\action -> Signal.send actions.address action) - ) - (Signal.merge signCommunication serverCommunications.signal) - ---------------------------------------- - -port persona : Signal String -port persona = Signal.map Persona.toString operations.signal - ---------------------------------------- - -port sign : Signal Json.Value +-- Output ports -signCommunication : Signal SC.Communication -signCommunication = - Signal.map (Sign.toServerCommunication << Sign.decodeOperation) sign +port askSignIn : Signal String +port askSignIn = Signal.map toString operations.signal |