@tanstack/query-core
Advanced tools
Comparing version
@@ -21,3 +21,3 @@ import { | ||
} | ||
var _client, _result, _queries, _observers, _combinedResult, _combineResult, combineResult_fn, _findMatchingObservers, findMatchingObservers_fn, _onUpdate, onUpdate_fn, _notify, notify_fn; | ||
var _client, _result, _queries, _observers, _combinedResult, _lastCombine, _lastResult, _combineResult, combineResult_fn, _findMatchingObservers, findMatchingObservers_fn, _onUpdate, onUpdate_fn, _notify, notify_fn; | ||
var QueriesObserver = class extends Subscribable { | ||
@@ -35,2 +35,4 @@ constructor(client, queries, _options) { | ||
__privateAdd(this, _combinedResult, void 0); | ||
__privateAdd(this, _lastCombine, void 0); | ||
__privateAdd(this, _lastResult, void 0); | ||
__privateSet(this, _client, client); | ||
@@ -133,6 +135,16 @@ __privateSet(this, _queries, []); | ||
_combinedResult = new WeakMap(); | ||
_lastCombine = new WeakMap(); | ||
_lastResult = new WeakMap(); | ||
_combineResult = new WeakSet(); | ||
combineResult_fn = function(input, combine) { | ||
if (combine) { | ||
return replaceEqualDeep(__privateGet(this, _combinedResult), combine(input)); | ||
if (!__privateGet(this, _combinedResult) || __privateGet(this, _result) !== __privateGet(this, _lastResult) || combine !== __privateGet(this, _lastCombine)) { | ||
__privateSet(this, _lastCombine, combine); | ||
__privateSet(this, _lastResult, __privateGet(this, _result)); | ||
__privateSet(this, _combinedResult, replaceEqualDeep( | ||
__privateGet(this, _combinedResult), | ||
combine(input) | ||
)); | ||
} | ||
return __privateGet(this, _combinedResult); | ||
} | ||
@@ -139,0 +151,0 @@ return input; |
@@ -20,2 +20,4 @@ // src/queriesObserver.ts | ||
#combinedResult; | ||
#lastCombine; | ||
#lastResult; | ||
constructor(client, queries, _options) { | ||
@@ -116,3 +118,11 @@ super(); | ||
if (combine) { | ||
return replaceEqualDeep(this.#combinedResult, combine(input)); | ||
if (!this.#combinedResult || this.#result !== this.#lastResult || combine !== this.#lastCombine) { | ||
this.#lastCombine = combine; | ||
this.#lastResult = this.#result; | ||
this.#combinedResult = replaceEqualDeep( | ||
this.#combinedResult, | ||
combine(input) | ||
); | ||
} | ||
return this.#combinedResult; | ||
} | ||
@@ -119,0 +129,0 @@ return input; |
{ | ||
"name": "@tanstack/query-core", | ||
"version": "5.28.13", | ||
"version": "5.29.0", | ||
"description": "The framework agnostic core that powers TanStack Query", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -43,2 +43,4 @@ import { notifyManager } from './notifyManager' | ||
#combinedResult?: TCombinedResult | ||
#lastCombine?: CombineFn<TCombinedResult> | ||
#lastResult?: Array<QueryObserverResult> | ||
@@ -185,3 +187,16 @@ constructor( | ||
if (combine) { | ||
return replaceEqualDeep(this.#combinedResult, combine(input)) | ||
if ( | ||
!this.#combinedResult || | ||
this.#result !== this.#lastResult || | ||
combine !== this.#lastCombine | ||
) { | ||
this.#lastCombine = combine | ||
this.#lastResult = this.#result | ||
this.#combinedResult = replaceEqualDeep( | ||
this.#combinedResult, | ||
combine(input), | ||
) | ||
} | ||
return this.#combinedResult | ||
} | ||
@@ -188,0 +203,0 @@ return input as any |
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
1863594
0.24%26571
0.22%19
5.56%31
3.33%5
150%350
-0.57%