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

useTracker and concurrent mode/suspense #336

Open
OliverColeman opened this issue Jun 20, 2021 · 2 comments
Open

useTracker and concurrent mode/suspense #336

OliverColeman opened this issue Jun 20, 2021 · 2 comments
Labels
in-discussion We are still discussing how to solve or implement it

Comments

@OliverColeman
Copy link

OliverColeman commented Jun 20, 2021

Just wondering how or if it's possible to integrate React Suspense with useTracker. The documentation about useTracker mentions Suspense integration, but I can find no examples of this. I think the Suspense API requires data loaders to throw a promise when data is loading (?), and after a quick scan of the useTracker code it looks like useTracker itself doesn't do this, so perhaps it's not possible out of the box?

@CaptainN
Copy link
Contributor

useTracker supports suspense in that it will work, and properly clean up in suspended scenarios. The same goes for error boundaries and concurrent mode. It doesn't support throwing promises though, for a bunch of complexity reasons. Basically, computations are very flexible, and there are a lot of edge cases to consider.

It should be fairly straight forward to use a separate hook though. Meteor.subscribe supports a callback in it's use. You could tie that to a Promise and throw it, and use it that way to get suspense. Then use useTracker only for your queries.

@CaptainN
Copy link
Contributor

BTW, useTracker without deps array might "just work" with suspense.

@filipenevola filipenevola added the in-discussion We are still discussing how to solve or implement it label Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-discussion We are still discussing how to solve or implement it
Projects
None yet
Development

No branches or pull requests

3 participants