Skip to content

Instantly share code, notes, and snippets.

@forki
Created November 14, 2017 10:34
Show Gist options
  • Save forki/4169a2376b25e498d52584cf5e5e75e4 to your computer and use it in GitHub Desktop.
Save forki/4169a2376b25e498d52584cf5e5e75e4 to your computer and use it in GitHub Desktop.
let update (msg:Msg) model : Model*Cmd<Msg> =
match msg with
| ...
| Error exn ->
printfn "error: %A" exn.Message
model, Cmd.none
| Noop _ ->
model, Cmd.none
| NewHeartBeat (chargingPointID,heartbeat) ->
// ...
| Send m -> model, Cmd.ofFunc (Elmish.WebSocket.send model.WebSocket) m Noop Error
| ServerMsg Elmish.WebSocket.WebSocketMsg.Connected ->
{ model with Connected = true }, Cmd.ofMsg (Send SendHeartBeats)
| ServerMsg Elmish.WebSocket.WebSocketMsg.Disconnected -> { model with Connected = false }, Cmd.none
| ServerMsg (Elmish.WebSocket.WebSocketMsg.Error e) ->
printfn "error: %A" e
model, Cmd.none
| ServerMsg (Elmish.WebSocket.WebSocketMsg.Data msg) ->
model,
match msg with
| HeartBeat(chargingPointID,heartbeat) -> NewHeartBeat(chargingPointID,heartbeat)
|> Cmd.ofMsg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment