Skip to content

Instantly share code, notes, and snippets.

@brodo
Created November 19, 2015 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brodo/6495e486648d235e10a5 to your computer and use it in GitHub Desktop.
Save brodo/6495e486648d235e10a5 to your computer and use it in GitHub Desktop.
-- Actions
type Action =
NoOp
| PlayerList PlayerList.Action
| Games Games.Action
| Global Globals.GlobalAction
-- Update
update : Action -> Model -> Model
update action model =
case action of
NoOp ->
model
PlayerList act ->
let
(players, globalAction) =
PlayerList.update act model.playerList
newModel = updateGlobal globalAction model
in
{ newModel |
playerList <- players
}
Games act ->
let
(games, globalAction) =
Games.update act model.games
newModel = updateGlobal globalAction model
in
{ newModel |
games <- games
}
Global act ->
updateGlobal act model
updateGlobal : Globals.GlobalAction -> Model -> Model
updateGlobal action model =
{ model |
games <- Games.updateGlobal action model.games
, playerList <- PlayerList.updateGlobal action model.playerList
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment