-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocket client #4
Comments
This was more of a comment rather than an issue. I apologize if I didn't follow the right protocol. This is my fist such post on github though I have been a passive user of many open source projects for a while. Piotr's are my favorites. |
Hey and welcome @mudont 🙌 Your suggestions are welcomed here :) I like the idea of WebSocket client, and from top of my head, I feel I would create a The second part is more challenging I will think about it later when I have some free time to do that. |
Thanks Piotr. |
I think this can be closed. At least as far as I am concerned. Thanks for the advice. I see you plan implement a WebSocket client. Great. I look forward to seeing that. I tried to move my WS initialization to the epic, but I couldn't figure out how to get hold of the disppatch function to pass it from the epic to the websocket service. Maybe have the store pass it to the Epics like how services are passed? I also see you are implementing authentication. How I wish I had stared my project after you were done with this. I struggled with auth (though I didn't mind learning about it) and managed to get Auth0 authentication working inside this framework, though code is not as clean as your example. |
Even though still a WIP, this project has been a great help to me already.
I am adding a websocket client in my app, and would have loved to see an example of that doing idiomatically.
What I have done so far is add a ws service and ws feature with actions and epics.
The server pushes 4 (for now) kinds of objects, and and the ws client turns the incoming data into actions and the the data end up in the redux store.
I am reasonably comfortable (though far from certain) that this approach broadly is idiomatic and reasonable.
But one detail seems like a hack. The ws service needs the Redux dispatch function to be able to generate redux actions from the server pushed data. My solution so far has been to call the ws service's initialization function from store/index.ts explicitly passing store.dispatch to it.
I am wondering how to improve this. Maybe I should use react-redux connect() to wrap the websocket initialization function and call it from App.tsx ?
The other challenge that I haven't yet tried to implement, is I would would like to implement a semi-synchronous-feeling request/response/error/timeout flow over websockets similar to how REST API requests work . I suspect I have to deal with a mux/demux issue as there can be more than one request active, and need to match responses to the right requests. I will come up with something, but I suspect others have already invented clever ways of doing it that will never occur to me.
The text was updated successfully, but these errors were encountered: