cache.dispatch use async/await
See original GitHub issuecache.dispatch = async (...args) => {
const type = argsToString(args)
const timeout = getTimeout(args, option)
if (timeout) {
const now = Date.now()
if (!timeoutCache.has(type)) {
timeoutCache.set(type, now)
} else {
const timeoutOfCurrentType = timeoutCache.get(type)
// console.log(now - timeout, timeoutOfCurrentType)
if (now - timeout > timeoutOfCurrentType) {
cache.delete(type)
timeoutCache.delete(type)
}
}
}
if (!cache.has(type)) {
cache.set(type, await store.dispatch.apply(store, args))
}
cache.dispatch 使用async/await,当dispatch报错时不set cache?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why is my redux app not caching an async api call in redux ...
1. You might need a conditional in useEffect -- only dispatch if selectAllCountries. · If I take selectAllCountrires.data away from the useEffect ...
Read more >JavaScript Async - Cache - I Programmer
To store a new key/value pair in the cache you would use either: await myCache.add(request);. which loads the response from request and stores ......
Read more >Async/Await - Best Practices in Asynchronous Programming
Async void methods have different composing semantics. Async methods returning Task or Task<T> can be easily composed using await, Task.WhenAny, Task.
Read more >Async actions in bare Redux with Thunk or custom middleware
Learn how to manage asynchronous actions in React apps with Redux Toolkit, or a bare Redux implementation with custom middleware.
Read more >Dispatch This: Using Apollo Client 3 as a State Management ...
Forming and sending the request · Updating async states (loading, error, data) · Normalizing and caching the response · Saving bandwidth by ...
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 FreeTop 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
Top GitHub Comments
Save
Promise
as cache value is smaller, easier and less invasive than intercept it’s resolution/rejection reason. But, maybe is not the right choice, so I’ll create another issue with this dicussion.I know it caches promise, but why it is necessary to cache a rejected promise ?