Skip to content

Instantly share code, notes, and snippets.

@farism
Created March 7, 2017 07:05
Show Gist options
  • Save farism/53077caea08623bc70a2e7b6a5ea1817 to your computer and use it in GitHub Desktop.
Save farism/53077caea08623bc70a2e7b6a5ea1817 to your computer and use it in GitHub Desktop.
-- MAIN
type Msg
= UI UI.Msg
| Receive String
| Send String
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
UI uiMsg ->
let
( ui, uiCmds ) =
UI.update uiMsg model.ui
in
( { model | ui = ui }, Cmd.map UI uiCmds )
Receive subMsg ->
model ! []
Send subMsg ->
( model, WebSocket.send endpoint subMsg )
-- UI
type Msg
= Chat Chat.Msg
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Chat subMsg ->
let
( chat, chatCmds ) =
Chat.update subMsg model.chat
in
( { model | chat = chat }, Cmd.map Chat chatCmds )
-- CHAT
type Msg
= UpdateField String
| Send String
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
UpdateField input ->
{ model | field = input } ! []
Send input ->
{ model | field = "" } ! []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment