oscartbeaumont / rspc

A framework for building typesafe web backends in Rust
https://rspc.dev
MIT License
1.1k stars 50 forks source link

Type-narrowing subscription key #198

Open oscartbeaumont opened 11 months ago

oscartbeaumont commented 11 months ago

Idk, if I will do this but it might be a good idea.

Eg. current code:

useLibrarySubscription(['jobs.progress', activeJobId as string], {
  onData: setRealtimeUpdate,
  enabled: !!activeJobId && !showChildJobs
});

Making something like this work:

useLibrarySubscription(() => !!activeJobId && !showChildJobs ? undefined : ['jobs.progress', activeJobId], {
  onData: setRealtimeUpdate,
});