If you have trpc configured with a custom transformer, the transformer is not called on emitted data from the router. The receiving end calls deserialize resulting un undefined edited data from the subscription.
The example below uses superjson and the onData of the subscription will return undefined because the receiving end is expecting the data to be serialized with the provided transformer.
// background
const t = initTRPC.create({ transformer: superjson });
const appRouter = t.router({
echoSubscription: t.procedure
.input(z.object({ payload: z.string(), date: z.date() }))
.subscription(({ input }) =>
observable<typeof input>((emit) => {
emit.next(input);
}),
),
});
// content script
trpc.nestedRouter.echoSubscription.subscribe(
{ payload: 'subscription1', date: date1 },
{
onData: (data) => {
// data will be undefined here
}
}
)
If you have trpc configured with a custom transformer, the transformer is not called on emitted data from the router. The receiving end calls
deserializeresulting un undefined edited data from the subscription.The example below uses superjson and the
onDataof the subscription will return undefined because the receiving end is expecting the data to be serialized with the provided transformer.