Derock
Derock14mo ago

Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?

I have an application, and on certain pages I need live data. Is there a way to only have tRPC open a websocket for subscriptions and then use another link otherwise? I would like for the solution to disconnect from WS when all subscriptions have been ended, so no dangling WS connections.
5 Replies
Nick
Nick14mo ago
Are you looking for splitLink?
Derock
DerockOP14mo ago
ooh did not know that existed will look into that thanks will splitLink keep an open WS even if it's not needed?
Nick
Nick14mo ago
Try it! I haven't got any experience with our subscriptions
Derock
DerockOP14mo ago
it does it opens a ws on page load, even if it's not needed found this! turns out there's a lazy mode nevermind dunno what happened to that PR but looks like it was never merged
Alex / KATT 🐱
Alex / KATT 🐱14mo ago
Feel free to pick up lazy mode

Did you find this page helpful?