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
Multiple Websocket connection ? #79
Comments
Hi @cubecleveland, Are you passing { share: true } in the option param? https://github.com/robtaussig/react-use-websocket#share-boolean |
Hi! Yes i solved it, i read through the code and i think the imlemetation is neat but the use case for me would not work in the way the socket was implemented and the share. Mainly im looking for a function that will only update the socket every interval...... Reason is im dealing with 100's of events per seconds. |
I'm glad you brought that up -- I have been meaning to implement a throttle param that does just that -- accept a duration, and batch messages in groups such that you only ever get one update per interval. I think I'll do that next! I think using the filter param is interesting and probably more performant than my next suggestion, but it will require abusing the filter callback:) alternatively, you can wrap useWebsocket with your own custom hook that batches the messages, but I'm struggling to imagine whether this would actually solve the performance problem of rapid updates since your component is already being updated by the internal hook. |
Correct. IMHO..... using the filter doesnt work and it will require some refactoring . In the meantime, i just implemented my owb hook not using your library but i would love to once this feature is enabled... Thanks so much for your great work! |
Not sure if related but is there a way to share connections between different paths on the same socket URL? So imagine I had a |
Hello,
Not sure if this is an issue or a discussion or just not understangin the code.. :)
Looked at the code and it seems like every component is opening a new WebSocket connection via new WebSocket()
I cant really spot the 'sharing mechanism' Can u assist ands let me know where in the code the compoenent actually shares the connection that akleady exist s?
Thanks
R
The text was updated successfully, but these errors were encountered: