Nhowka / Elmish.Bridge

Create client-server Fable-Elmish apps keeping a single mindset
MIT License
139 stars 17 forks source link

Single shared state #16

Closed pkese closed 5 years ago

pkese commented 5 years ago

Hi,

This is not really an issue report, but rather a personal question, so I'd like to excuse myself in advance for polluting this repository's issue tracker.

I've ported an existing app to Fable2 and in the process I had to find a new solution for Fable.Websockets.Elmish, so Elmish.Bridge seemed like a good solution.

It was only after much of the port was already completed, that I've found out that there's a slight change in the architecture...

My app has only one single "Elmish" state that is being shared and manipulated by all clients together, whereas Elmish.Bridge keeps a separate state for each client connection.

Now I'm trying to find an efficient way of recreating my original functionality (single state per app, rahter than one state per connection). Technically what I need to do is probably a single global mailbox processor into which all client's update calls get diverted.

My question is that Elmish.Bridge already has a Mailbox procesor for each client connection so I'm wondering if there is a simple way to use or somehow plug into the existing code rather than wrapping another mailbox processor around existing ones.

I'll appreciate any help or hints on how to best approach this situation
(I'm not yet familiar with the internals of Elmish.Bridge -- if possible I'd rather plug into existing code rather than forking the whole repository).

Nhowka commented 5 years ago

Hi! Maybe it would be possible to make some use of the ServerHub to send messages to everyone, but that won't be the really the same. The ServerHub will keep the current state from all connected clients but no state of itself, but if coupled with the extra mailbox to keep that state you probably can achieve what you need with little effort.

Not sure how the performance will be hit with that many indirections, but could work.

pkese commented 5 years ago

@Nhowka thanks for your response.
I took some time to look at the source code and the demo chat app and I think that Elmish.Bridge is probably not quite the right websocket abstraction for my need, so I will take a look at other options as well.