module Main ( main ) where {-| @docs main -} import Graphics.Element exposing (..) import Html exposing (Html) import Http import Task exposing (..) import Model exposing (Model, initialModel) import Model.Payment exposing (Payments, paymentsDecoder) import Update exposing (Action(..), actions, updateModel) import View.Page exposing (renderPage) import ServerCommunication exposing (serverCommunications, sendRequest) {-| main -} main : Signal Html main = Signal.map renderPage model model : Signal Model model = Signal.foldp updateModel initialModel actions.signal --------------------------------------- port fetchPayments : Task Http.Error () port fetchPayments = getPayments |> flip Task.andThen reportSuccess |> flip Task.onError reportError reportSuccess : Payments -> Task x () reportSuccess payments = Signal.send actions.address (UpdatePayments payments) reportError : Http.Error -> Task x () reportError error = Signal.send actions.address SignIn getPayments : Task Http.Error Payments getPayments = Http.get paymentsDecoder "/payments" --------------------------------------------------- port serverCommunicationsPort : Signal (Task Http.RawError ()) port serverCommunicationsPort = Signal.map (\comm -> sendRequest comm `Task.andThen` (Signal.send actions.address)) serverCommunications.signal