Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change useSubscription to be Suspense compatible #428

Open
c10b10 opened this issue Mar 11, 2024 · 1 comment
Open

Change useSubscription to be Suspense compatible #428

c10b10 opened this issue Mar 11, 2024 · 1 comment
Labels
react Feature requests related to React

Comments

@c10b10
Copy link

c10b10 commented Mar 11, 2024

I'm working on a real-time data heavy application and we'd like to integrate our subscriptions with Suspense.

Due to reasons having to do with uncertainty around race conditions we:

  • don't use the suggested useQuery + subscribeToMore pattern - this is because it's uncertain if there would be lost events between the moment the data is retrieved and useQuery the moment subscription starts
  • instead, we use the useSubscription hook directly and we return distinct cache manipulating events (INSERT, UPDATE, DELETE): we implement a wrapper that displays a loading state until the READY event is pushed. The computation is done with the onData callback.

We'd like to make this Suspense compatible but currently there's no way of capturing the subscription in a Promise. We'd need the be able to call a version of useSubscription in a promise and resolve the promise only when the READY event is detected.

Is anything like that planned or could I maybe do this some other way with the current API?

@jerelmiller jerelmiller added the react Feature requests related to React label Mar 11, 2024
@jerelmiller
Copy link
Member

Hey @c10b10 👋

Thanks for the request! This is certainly something we've seen come up before and we are certainly open to the idea! I can't promise a timeline, but appreciate the feature request so that we can gauge interest 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react Feature requests related to React
Projects
None yet
Development

No branches or pull requests

2 participants