Derock
Derock9mo 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
Nick9mo ago
Are you looking for splitLink?
Derock
Derock9mo 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
Nick9mo ago
Try it! I haven't got any experience with our subscriptions
Derock
Derock9mo 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 🐱
Feel free to pick up lazy mode