Retriggering async atoms with progress #2187
-
|
Hi, having a great experience using Jotai but now I'm encountering an issue. I need to do a query, which can take longer and returns a token/progress until it's done. Based on some dependencies (e.g. filters) I need to re-execute it. Currently I solved it somewhat like this (pseudo code): state.ts: Component.tsx: this works perfectly, but I would prefer not having to rely on the useEffect in my component to re-trigger the fetching when some of my dependencies change. Is there a better way to do this? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
This is an interesting use case. I think I've never heard of it. But, I think your approach is fairly reasonable.
Yeah. Recently, we introduced |
Beta Was this translation helpful? Give feedback.
This is an interesting use case. I think I've never heard of it.
Basically, you want to return a sequence asynchronously, so async iterable, or observable might fit. You may want to try
atomWithObservable.But, I think your approach is fairly reasonable.
Yeah. Recently, we introduced
atomEffectin https://github.com/jotaijs/jotai-effect, which would be more appropriate.