@@ -43,6 +43,7 @@ export class QueriesObserver<
43
43
#combinedResult?: TCombinedResult
44
44
#lastCombine?: CombineFn < TCombinedResult >
45
45
#lastResult?: Array < QueryObserverResult >
46
+ #observerMatches: Array < QueryObserverMatch > = [ ]
46
47
47
48
constructor (
48
49
client : QueryClient ,
@@ -106,6 +107,7 @@ export class QueriesObserver<
106
107
const prevObservers = this . #observers
107
108
108
109
const newObserverMatches = this . #findMatchingObservers( this . #queries)
110
+ this . #observerMatches = newObserverMatches
109
111
110
112
// set options for the new observers to notify of changes
111
113
newObserverMatches . forEach ( ( match ) =>
@@ -177,17 +179,15 @@ export class QueriesObserver<
177
179
return this . #combineResult( r ?? result , combine )
178
180
} ,
179
181
( ) => {
180
- return this . #trackResult( result , queries )
182
+ return this . #trackResult( result , matches )
181
183
} ,
182
184
]
183
185
}
184
186
185
187
#trackResult(
186
188
result : Array < QueryObserverResult > ,
187
- queries : Array < QueryObserverOptions > ,
189
+ matches : Array < QueryObserverMatch > ,
188
190
) {
189
- const matches = this . #findMatchingObservers( queries )
190
-
191
191
return matches . map ( ( match , index ) => {
192
192
const observerResult = result [ index ] !
193
193
return ! match . defaultedQueryOptions . notifyOnChangeProps
@@ -263,10 +263,8 @@ export class QueriesObserver<
263
263
#notify( ) : void {
264
264
if ( this . hasListeners ( ) ) {
265
265
const previousResult = this . #combinedResult
266
- const newResult = this . #combineResult(
267
- this . #trackResult( this . #result, this . #queries) ,
268
- this . #options?. combine ,
269
- )
266
+ const newTracked = this . #trackResult( this . #result, this . #observerMatches)
267
+ const newResult = this . #combineResult( newTracked , this . #options?. combine )
270
268
271
269
if ( previousResult !== newResult ) {
272
270
notifyManager . batch ( ( ) => {
0 commit comments