Created
March 7, 2017 07:05
-
-
Save farism/53077caea08623bc70a2e7b6a5ea1817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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