Re:The Elm Architecture
by CGamesPlay on Monday February 16, 2015 @11:08PM
(#9060615)
I ended up implementing this in JavaScript using Rx, but the core concept is the same:
Incoming requests: --a------------->
Requests to server: ---b------------>
Responses from server: -----------d---->
Updates to app state: ---c--------e--->
a - User "sends message" to chat roomb - Handler for that action queues a request
c - Handler for that action also queues a local update
d - Server responds with the sent message
e - Handler for that response queues a local update
Yep, it was specifically when I wanted an application that would run a game loop involving round trips to the backend for every step that I ran into a lot of difficulty. Ports were not very clearly documented and I didn't find any examples, so I wound up writing Javascript instead.
Sending data isn't hard. Sending the mouse coordinates on a click to the server over a websocket is super easy.
There is, however, no easy way to consume data and send a response. To write an echo server, for example, you currently have to send the data to a javascript port and then read from the port to send it back.