johste
johste
TtRPC
Created by johste on 8/30/2023 in #❓-help
Need help identifying the generic client side type of procedures
Hi! I think my question is better explained by what I'm trying to achive than anything else: I like to create a function called "subscribe" that can receive any subscription procedure and subscribe to it: e.g (sudo code):
const onRandomNumberRecived = (n: number) => {}
subscribe(trpc.randomNumber, onRandomNumberRecived);
const onRandomNumberRecived = (n: number) => {}
subscribe(trpc.randomNumber, onRandomNumberRecived);
Below is the infered type, but I'm pretty sure there is an generic type to represent such a thing "somewhere":
(property) randomNumber: {
subscribe: SubscriptionResolver<BuildProcedure<"subscription", {
_config: RootConfig<{
ctx: {};
meta: object;
errorShape: DefaultErrorShape;
transformer: DefaultDataTransformer;
}>;
_ctx_out: {};
_input_in: typeof unsetMarker;
_input_out: typeof unsetMarker;
_output_in: typeof unsetMarker;
_output_out: typeof unsetMarker;
_meta: object;
}, Observable<{randomNumber: number;}, unknown>>>;
(property) randomNumber: {
subscribe: SubscriptionResolver<BuildProcedure<"subscription", {
_config: RootConfig<{
ctx: {};
meta: object;
errorShape: DefaultErrorShape;
transformer: DefaultDataTransformer;
}>;
_ctx_out: {};
_input_in: typeof unsetMarker;
_input_out: typeof unsetMarker;
_output_in: typeof unsetMarker;
_output_out: typeof unsetMarker;
_meta: object;
}, Observable<{randomNumber: number;}, unknown>>>;
I've been digging through the source code, but so far I had no luck reproducing it. Have anyone attempted something similar?
3 replies