async set atom remains cached
See original GitHub issueI have an async atom that looks like follows
export const someAsyncAtom = atom(
async (get) => {
const {data} = await getData();
return data;
},
async (get, set, update) => {
if (update) {
set(someAsyncAtom, update);
} else {
const {data} = await getData();
set(someAsyncAtom, data);
}
}
);
Now up until v0.16.8
if I wanted to imperatively refresh my data I could use something like
const updateData = useUpdateAtom(someAsyncAtom)
However starting with v.0.16.9
after calling updateData
every component that has
const data = useAtomValue(someAsyncAtom)
has now stale data that dates back to before calling the imperative refresh. Any ideas? This is a breaking change for our application.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (14 by maintainers)
Top Results From Across the Web
Asynchronous Data Queries - Recoil
Asynchronous Example The results are cached, so the query will only execute once per unique input. The interface of the selector is the...
Read more >Prefetch and cache chained async state? #390 - GitHub
Hello, I'm using useRecoilValueLoadable with async selectors, and have a chain of selectors that look something like this: atom --> async ...
Read more >Async — Jotai, primitive and flexible state management for ...
Using async atoms, you gain access to real-world data while still managing them directly from your atoms and with incredible ease. We can...
Read more >Make a java completable future cache atomic - Stack Overflow
I'm going leave it here just in case it becomes useful for somebody else. public class AsyncCache { ExecutorService executor = Executors.
Read more >Exploring Asynchronous Requests in Recoil - AppSignal Blog
In async requests, this becomes critically important because responses can be cached. When selector functions get parameter dependencies, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll link the document here to save others time 😃
https://jotai.org/docs/advanced-recipes/atom-creators#atom-with-refresh
It looks good. You are not really using the power of atomWithDefault in the example, are you? Yeah, you may want to open a new issue or discussion.