Subscription example not behaving like it should
Hey, I've recently wanted to make a subscription route and I've stumbled upon a problem. In the documentation it's said that you should return an
observable
with a callback that is triggered immediately. That however is not happening. I don't know if I don't understand this correctly of if the example is broken.
I'm using bun@1.1.10 with @trpc/server@11.0.0-rc.396.
The console.log
at the end prints []
and I thought the callback is triggered immediately. Any help would be appreciated.Solution:Jump to solution
Okay I get it now, in my actual project I was using
httpBatchLink
and wsLink
together insead of splitting them using splitLink
that's why the subscription wasn't going off.
```ts
export const api = createTRPCClient<AppRouter & WebSocketRouter>({
links: [...2 Replies
it doesn't start listening until you actually have a client listening to
onAdd
Solution
Okay I get it now, in my actual project I was using
httpBatchLink
and wsLink
together insead of splitting them using splitLink
that's why the subscription wasn't going off.
Thanks for help :)