@tanstack/vue-query
Advanced tools
Comparing version 5.62.12 to 5.62.16
@@ -44,7 +44,23 @@ // src/useQueries.ts | ||
); | ||
const [, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
const state = shallowRef(getCombinedResult()); | ||
const getOptimisticResult = () => { | ||
const [results, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
return getCombinedResult( | ||
results.map((result, index) => { | ||
return { | ||
...result, | ||
refetch: async (...args) => { | ||
const [{ [index]: query }] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
return query.refetch(...args); | ||
} | ||
}; | ||
}) | ||
); | ||
}; | ||
const state = shallowRef(getOptimisticResult()); | ||
let unsubscribe = () => { | ||
@@ -58,13 +74,5 @@ }; | ||
unsubscribe = observer.subscribe(() => { | ||
const [, getCombinedResultRestoring] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultRestoring(); | ||
state.value = getOptimisticResult(); | ||
}); | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultPersisted(); | ||
state.value = getOptimisticResult(); | ||
} | ||
@@ -74,17 +82,9 @@ }, | ||
); | ||
watch( | ||
defaultedQueries, | ||
() => { | ||
observer.setQueries( | ||
defaultedQueries.value, | ||
options | ||
); | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultPersisted(); | ||
}, | ||
{ flush: "sync" } | ||
); | ||
watch(defaultedQueries, (queriesValue) => { | ||
observer.setQueries( | ||
queriesValue, | ||
options | ||
); | ||
state.value = getOptimisticResult(); | ||
}); | ||
onScopeDispose(() => { | ||
@@ -91,0 +91,0 @@ unsubscribe(); |
@@ -44,7 +44,23 @@ // src/useQueries.ts | ||
); | ||
const [, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
const state = shallowRef(getCombinedResult()); | ||
const getOptimisticResult = () => { | ||
const [results, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
return getCombinedResult( | ||
results.map((result, index) => { | ||
return { | ||
...result, | ||
refetch: async (...args) => { | ||
const [{ [index]: query }] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
return query.refetch(...args); | ||
} | ||
}; | ||
}) | ||
); | ||
}; | ||
const state = shallowRef(getOptimisticResult()); | ||
let unsubscribe = () => { | ||
@@ -58,13 +74,5 @@ }; | ||
unsubscribe = observer.subscribe(() => { | ||
const [, getCombinedResultRestoring] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultRestoring(); | ||
state.value = getOptimisticResult(); | ||
}); | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultPersisted(); | ||
state.value = getOptimisticResult(); | ||
} | ||
@@ -74,17 +82,9 @@ }, | ||
); | ||
watch( | ||
defaultedQueries, | ||
() => { | ||
observer.setQueries( | ||
defaultedQueries.value, | ||
options | ||
); | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
options.combine | ||
); | ||
state.value = getCombinedResultPersisted(); | ||
}, | ||
{ flush: "sync" } | ||
); | ||
watch(defaultedQueries, (queriesValue) => { | ||
observer.setQueries( | ||
queriesValue, | ||
options | ||
); | ||
state.value = getOptimisticResult(); | ||
}); | ||
onScopeDispose(() => { | ||
@@ -91,0 +91,0 @@ unsubscribe(); |
{ | ||
"name": "@tanstack/vue-query", | ||
"version": "5.62.12", | ||
"version": "5.62.16", | ||
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue", | ||
@@ -53,3 +53,3 @@ "author": "Damian Osipiuk", | ||
"vue-demi": "^0.14.10", | ||
"@tanstack/query-core": "5.62.12" | ||
"@tanstack/query-core": "5.62.16" | ||
}, | ||
@@ -56,0 +56,0 @@ "devDependencies": { |
@@ -300,8 +300,28 @@ import { QueriesObserver } from '@tanstack/query-core' | ||
) | ||
const [, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
const state = shallowRef(getCombinedResult()) | ||
const getOptimisticResult = () => { | ||
const [results, getCombinedResult] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
return getCombinedResult( | ||
results.map((result, index) => { | ||
return { | ||
...result, | ||
refetch: async (...args: Array<any>) => { | ||
const [{ [index]: query }] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
return query!.refetch(...args) | ||
}, | ||
} | ||
}), | ||
) | ||
} | ||
const state = shallowRef(getOptimisticResult()) | ||
let unsubscribe = () => { | ||
@@ -317,14 +337,6 @@ // noop | ||
unsubscribe = observer.subscribe(() => { | ||
const [, getCombinedResultRestoring] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
state.value = getCombinedResultRestoring() | ||
state.value = getOptimisticResult() | ||
}) | ||
// Subscription would not fire for persisted results | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
state.value = getCombinedResultPersisted() | ||
state.value = getOptimisticResult() | ||
} | ||
@@ -335,17 +347,9 @@ }, | ||
watch( | ||
defaultedQueries, | ||
() => { | ||
observer.setQueries( | ||
defaultedQueries.value, | ||
options as QueriesObserverOptions<TCombinedResult>, | ||
) | ||
const [, getCombinedResultPersisted] = observer.getOptimisticResult( | ||
defaultedQueries.value, | ||
(options as QueriesObserverOptions<TCombinedResult>).combine, | ||
) | ||
state.value = getCombinedResultPersisted() | ||
}, | ||
{ flush: 'sync' }, | ||
) | ||
watch(defaultedQueries, (queriesValue) => { | ||
observer.setQueries( | ||
queriesValue, | ||
options as QueriesObserverOptions<TCombinedResult>, | ||
) | ||
state.value = getOptimisticResult() | ||
}) | ||
@@ -352,0 +356,0 @@ onScopeDispose(() => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325
6
1
114
707008
7956
+ Added@tanstack/query-core@5.62.16(transitive)
- Removed@tanstack/query-core@5.62.12(transitive)
Updated@tanstack/query-core@5.62.16