Why not use Go? It makes this very easy via channels. Go is also very easy to learn.
Discussion
Because I'm writing a web client
I see.
Consider ReScript, it may be the ideal solution. It is certainly more flexible than Elm and many friends or mine loved it.
Unfortunately ReScript doesn’t support reactive programming directly.
It could use RxJS and also an alternative called ReX:
