|
@@ -8,6 +8,7 @@ type CreateQueryPubOptions = {
|
|
|
cacheTimeout?: number,
|
|
|
hidePendingOnRefresh?: boolean
|
|
|
avoidRepeatInProgress?: boolean,
|
|
|
+ forceRefreshAfterTimeout?: boolean,
|
|
|
}
|
|
|
|
|
|
enum PromiseStatus {
|
|
@@ -103,19 +104,20 @@ export default (options:CreateQueryPubOptions) => {
|
|
|
|
|
|
|
|
|
|
|
|
- return currentPromises.queries[promiseName][stringifiedArgs] = makeQuery(...args).then(payload => queryPub.queries[promiseName][stringifiedArgs] = {
|
|
|
- status: 'FULFILLED',
|
|
|
- payload,
|
|
|
- timeStamp: Date.now(),
|
|
|
- cacheTags: cacheTagFunc(payload),
|
|
|
- timeoutId: options.cacheTimeout ? setTimeout(() =>forceQuery(...args), options.cacheTimeout) : null
|
|
|
- },
|
|
|
- error => queryPub.queries[promiseName][stringifiedArgs] = {
|
|
|
- status: 'REJECTED',
|
|
|
- error,
|
|
|
- timeStamp: Date.now(),
|
|
|
- timeoutId: options.cacheTimeout ? setTimeout(() =>forceQuery(...args), options.cacheTimeout) : null
|
|
|
- })
|
|
|
+ return currentPromises.queries[promiseName][stringifiedArgs] = makeQuery(...args)
|
|
|
+ .then(payload => queryPub.queries[promiseName][stringifiedArgs] = {
|
|
|
+ status: 'FULFILLED',
|
|
|
+ payload,
|
|
|
+ timeStamp: Date.now(),
|
|
|
+ cacheTags: cacheTagFunc(payload),
|
|
|
+ timeoutId: options.cacheTimeout && options.forceRefreshAfterTimeout ? setTimeout(() =>forceQuery(...args), options.cacheTimeout) : null
|
|
|
+ },
|
|
|
+ error => queryPub.queries[promiseName][stringifiedArgs] = {
|
|
|
+ status: 'REJECTED',
|
|
|
+ error,
|
|
|
+ timeStamp: Date.now(),
|
|
|
+ timeoutId: options.cacheTimeout && options.forceRefreshAfterTimeout ? setTimeout(() =>forceQuery(...args), options.cacheTimeout) : null
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const hookName = `use${promiseName[0].toUpperCase() + promiseName.slice(1) + (isMutation ? 'Mutation' : 'Query')}`
|