Elmish.Bridge icon indicating copy to clipboard operation
Elmish.Bridge copied to clipboard

Handling WebSocket Open Events

Open collinkruger opened this issue 4 years ago • 5 comments

Hi @Nhowka,

Thank you for providing this great library to the community.

In a recent project I had to update the Client/Library.fs file to include a withWhenOpened function so that I could listen for WebSocket open events.

Is this a feature you think should be included in your library? If so, would you like for me to submit a pull-request with this feature added?

collinkruger avatar Feb 23 '20 13:02 collinkruger

Hi, thanks for using it!

About the use case, how different is it from having the server sending a message to the client on its init function? That should behave as same, as that message will go through as the socket opens.

There is another information that are you using about the socket on that function that a server message wouldn't be enough?

Nhowka avatar Feb 23 '20 14:02 Nhowka

Now that you mention that, that sounds like the better approach.

I have some root level UI elements that I want disabled until a connection is established. Also, due to websockets being an application level concept, I had thought about the problem in those terms.

To your point, in my situation performing a projection off of the nested model is probably a better approach. (single source of truth, single concept, etc.)

I've now rewritten that part of my application to use projections off of the nested model and it is working perfectly.

Thank you for the feedback!

collinkruger avatar Feb 23 '20 15:02 collinkruger