Feature request: Conditional agent connection in react
When using the useAgent hook in react it would be useful to be able to provide a enabled?: boolean parameter as part of the agent options (much like React Query does) where the websocket connection is only started once the enabled parameter returns true.
You can pass startClosed: true, to useAgent, and then call agent.reconnect() when needed, will that work?
You can pass
startClosed: true,touseAgent, and then callagent.reconnect()when needed, will that work?
It is not as elegant as the enabled? hook known from react query, because I still have to write the useEffect then to trigger the reconnect. But it absolutely does solve the problem I have 🔥
Thank you very much 🙏
(I'll refrain from closing this issue in case it is feedback you want to work with. If you don't feel like it's worthwhile, feel free to close the issue 🙌 )
yeah maybe we want to implement enabled anyway (upstream in partysocket). let's leave this open for a while.