Get updates via , Github, or RSS | About

Episode 24: WebSockets Feb 16, 2017

WebSockets open up your app to realtime communication with the server. Using the WebSocket library to handle the connections will unburden you from worrying about the messy details, so you can focus on improving your app for your users.

Examples

Main.elm

main =
    Navigation.program
        UrlChange
        { subscriptions =
            (\model ->
                WS.listen wsAddress Heard
            )
        }

update msg model =
    case msg of
        DealHand ->
            let
                cmd =
                    WS.send wsAddress "payload"
            in
                model ! [ cmd ]

        Heard msg ->
            let
                _ =
                    Debug.log "msg" msg
            in
                model ! []