-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
Support primitive atoms with a Promise as the initial value. #430
Comments
Thanks for opening this up. This is something I thought about too. Not sure if it can be implemented in a straightforward way. React Suspense contract is to wait until the promise is resolved, right? So, we need to return a new promise. I can try that. I wonder if anyone has an idea for typing. |
(Also wondering if this is possibly related with #426. In this case, it's a priority for me.) Edit: on second thought, this is not related. |
Accidentally closed this. |
https://codesandbox.io/s/jotai-subscription-1-forked-ol4rv |
Oh my, the same issue can be reproduced with a normal async read atom. |
let me create a new issue. done: #434 |
I think this would be a powerful feature. It would allow one to create an atom that is initially suspended, and then un-suspend it later, when data is available. See, for example, a simple subscription example. This was derived from something I was working in for firebase authentication. The same idea would work for firestore subscriptions. Dai-shi also mentioned that atomWithQuery() could be improved if this were supported.
Work-arounds are possible using a combination of atoms and useEffect, but in my experience they're very tricky to get exactly right and they require quite a bit of code.
In addition to the additional power, it seems like it might be better to implement this than try to write documentation explaining why it doesn't work. :-)
The text was updated successfully, but these errors were encountered: