Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
8 replies
Integra

tRPC splitLink wsLink/httpBatchLink explanation please

I am still struggling to fully understand which approach should I use for tRPC subscriptions. Currently I have a an app created with create-3t-app with websocket server and handler up and running. As in the starter example I am using eventEmitter to trigger emit an event from a mutation and subscription that listens to that event. If I conditionally use wsLink || httpBatchLink depending by the window availability, it works as aspected. If I use splitLink base on condition op.type === "subscription" the eventEmitter is trigger but the event is lost without reaching the subscription procedure. I understand that using eventEmitter is not ideal, but still I would really appreciate if anybody could explain me the logic behind this behavior
Was this page helpful?