cha0sg0d
cha0sg0d6mo ago

Subscription for a specific user

How can I create a TRPC subscription that takes a userId? When updates occur elsewhere in my app, I want to broadcast them to relevant users. Trying to avoid a full Socket.io rooms implementation
2 Replies
BeBoRE
BeBoRE6mo ago
If your subscriptions run on the same process as your mutations, you can just use the eventEmitter class where your subscription listents to certain events and filters out the onces relevent to your user and the mutation emits them. If your subscriptions run on a different process, or you are expecting to scale your app, you might want to look at a solution like Redis PubSub.
cha0sg0d
cha0sg0d5mo ago
thanks!