@@ -43,6 +43,7 @@ export class QueriesObserver<
4343 #combinedResult?: TCombinedResult
4444 #lastCombine?: CombineFn < TCombinedResult >
4545 #lastResult?: Array < QueryObserverResult >
46+ #observerMatches: Array < QueryObserverMatch > = [ ]
4647
4748 constructor (
4849 client : QueryClient ,
@@ -106,6 +107,7 @@ export class QueriesObserver<
106107 const prevObservers = this . #observers
107108
108109 const newObserverMatches = this . #findMatchingObservers( this . #queries)
110+ this . #observerMatches = newObserverMatches
109111
110112 // set options for the new observers to notify of changes
111113 newObserverMatches . forEach ( ( match ) =>
@@ -177,17 +179,15 @@ export class QueriesObserver<
177179 return this . #combineResult( r ?? result , combine )
178180 } ,
179181 ( ) => {
180- return this . #trackResult( result , queries )
182+ return this . #trackResult( result , matches )
181183 } ,
182184 ]
183185 }
184186
185187 #trackResult(
186188 result : Array < QueryObserverResult > ,
187- queries : Array < QueryObserverOptions > ,
189+ matches : Array < QueryObserverMatch > ,
188190 ) {
189- const matches = this . #findMatchingObservers( queries )
190-
191191 return matches . map ( ( match , index ) => {
192192 const observerResult = result [ index ] !
193193 return ! match . defaultedQueryOptions . notifyOnChangeProps
@@ -263,10 +263,8 @@ export class QueriesObserver<
263263 #notify( ) : void {
264264 if ( this . hasListeners ( ) ) {
265265 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 )
270268
271269 if ( previousResult !== newResult ) {
272270 notifyManager . batch ( ( ) => {
0 commit comments