@tanstack/query-core 5.0.0-alpha.32 → 5.0.0-alpha.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/index.d.ts +1 -0
- package/build/lib/queriesObserver.d.ts +12 -5
- package/build/lib/queriesObserver.esm.js +49 -10
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js +49 -10
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/queriesObserver.mjs +32 -10
- package/build/lib/queriesObserver.mjs.map +1 -1
- package/build/umd/index.development.js +31 -10
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/queriesObserver.ts +63 -13
- package/build/lib/focusManager.d.ts.map +0 -1
- package/build/lib/hydration.d.ts.map +0 -1
- package/build/lib/index.d.ts.map +0 -1
- package/build/lib/infiniteQueryBehavior.d.ts.map +0 -1
- package/build/lib/infiniteQueryObserver.d.ts.map +0 -1
- package/build/lib/mutation.d.ts.map +0 -1
- package/build/lib/mutationCache.d.ts.map +0 -1
- package/build/lib/mutationObserver.d.ts.map +0 -1
- package/build/lib/notifyManager.d.ts.map +0 -1
- package/build/lib/onlineManager.d.ts.map +0 -1
- package/build/lib/queriesObserver.d.ts.map +0 -1
- package/build/lib/query.d.ts.map +0 -1
- package/build/lib/queryCache.d.ts.map +0 -1
- package/build/lib/queryClient.d.ts.map +0 -1
- package/build/lib/queryObserver.d.ts.map +0 -1
- package/build/lib/removable.d.ts.map +0 -1
- package/build/lib/retryer.d.ts.map +0 -1
- package/build/lib/subscribable.d.ts.map +0 -1
- package/build/lib/tests/focusManager.test.d.ts.map +0 -1
- package/build/lib/tests/hydration.test.d.ts.map +0 -1
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +0 -1
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +0 -1
- package/build/lib/tests/mutationCache.test.d.ts.map +0 -1
- package/build/lib/tests/mutationObserver.test.d.ts.map +0 -1
- package/build/lib/tests/mutations.test.d.ts.map +0 -1
- package/build/lib/tests/notifyManager.test.d.ts.map +0 -1
- package/build/lib/tests/onlineManager.test.d.ts.map +0 -1
- package/build/lib/tests/queriesObserver.test.d.ts.map +0 -1
- package/build/lib/tests/query.test.d.ts.map +0 -1
- package/build/lib/tests/queryCache.test.d.ts.map +0 -1
- package/build/lib/tests/queryClient.test.d.ts.map +0 -1
- package/build/lib/tests/queryObserver.test.d.ts.map +0 -1
- package/build/lib/tests/utils.d.ts.map +0 -1
- package/build/lib/tests/utils.test.d.ts.map +0 -1
- package/build/lib/types.d.ts.map +0 -1
- package/build/lib/utils.d.ts.map +0 -1
|
@@ -2279,15 +2279,19 @@
|
|
|
2279
2279
|
#result;
|
|
2280
2280
|
#queries;
|
|
2281
2281
|
#observers;
|
|
2282
|
-
|
|
2282
|
+
#options;
|
|
2283
|
+
#combinedResult;
|
|
2284
|
+
constructor(client, queries, options) {
|
|
2283
2285
|
super();
|
|
2284
2286
|
this.#client = client;
|
|
2285
2287
|
this.#queries = [];
|
|
2286
|
-
this.#result = [];
|
|
2287
2288
|
this.#observers = [];
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2289
|
+
this.#setResult([]);
|
|
2290
|
+
this.setQueries(queries, options);
|
|
2291
|
+
}
|
|
2292
|
+
#setResult(value) {
|
|
2293
|
+
this.#result = value;
|
|
2294
|
+
this.#combinedResult = this.#combineResult(value);
|
|
2291
2295
|
}
|
|
2292
2296
|
onSubscribe() {
|
|
2293
2297
|
if (this.listeners.size === 1) {
|
|
@@ -2309,8 +2313,9 @@
|
|
|
2309
2313
|
observer.destroy();
|
|
2310
2314
|
});
|
|
2311
2315
|
}
|
|
2312
|
-
setQueries(queries, notifyOptions) {
|
|
2316
|
+
setQueries(queries, options, notifyOptions) {
|
|
2313
2317
|
this.#queries = queries;
|
|
2318
|
+
this.#options = options;
|
|
2314
2319
|
notifyManager.batch(() => {
|
|
2315
2320
|
const prevObservers = this.#observers;
|
|
2316
2321
|
const newObserverMatches = this.#findMatchingObservers(this.#queries);
|
|
@@ -2324,7 +2329,7 @@
|
|
|
2324
2329
|
return;
|
|
2325
2330
|
}
|
|
2326
2331
|
this.#observers = newObservers;
|
|
2327
|
-
this.#
|
|
2332
|
+
this.#setResult(newResult);
|
|
2328
2333
|
if (!this.hasListeners()) {
|
|
2329
2334
|
return;
|
|
2330
2335
|
}
|
|
@@ -2340,7 +2345,7 @@
|
|
|
2340
2345
|
});
|
|
2341
2346
|
}
|
|
2342
2347
|
getCurrentResult() {
|
|
2343
|
-
return this.#
|
|
2348
|
+
return this.#combinedResult;
|
|
2344
2349
|
}
|
|
2345
2350
|
getQueries() {
|
|
2346
2351
|
return this.#observers.map(observer => observer.getCurrentQuery());
|
|
@@ -2349,7 +2354,23 @@
|
|
|
2349
2354
|
return this.#observers;
|
|
2350
2355
|
}
|
|
2351
2356
|
getOptimisticResult(queries) {
|
|
2352
|
-
|
|
2357
|
+
const matches = this.#findMatchingObservers(queries);
|
|
2358
|
+
const result = matches.map(match => match.observer.getOptimisticResult(match.defaultedQueryOptions));
|
|
2359
|
+
return [result, r => {
|
|
2360
|
+
return this.#combineResult(r ?? result);
|
|
2361
|
+
}, () => {
|
|
2362
|
+
return matches.map((match, index) => {
|
|
2363
|
+
const observerResult = result[index];
|
|
2364
|
+
return !match.defaultedQueryOptions.notifyOnChangeProps ? match.observer.trackResult(observerResult) : observerResult;
|
|
2365
|
+
});
|
|
2366
|
+
}];
|
|
2367
|
+
}
|
|
2368
|
+
#combineResult(input) {
|
|
2369
|
+
const combine = this.#options?.combine;
|
|
2370
|
+
if (combine) {
|
|
2371
|
+
return replaceEqualDeep(this.#combinedResult, combine(input));
|
|
2372
|
+
}
|
|
2373
|
+
return input;
|
|
2353
2374
|
}
|
|
2354
2375
|
#findMatchingObservers(queries) {
|
|
2355
2376
|
const prevObservers = this.#observers;
|
|
@@ -2384,7 +2405,7 @@
|
|
|
2384
2405
|
#onUpdate(observer, result) {
|
|
2385
2406
|
const index = this.#observers.indexOf(observer);
|
|
2386
2407
|
if (index !== -1) {
|
|
2387
|
-
this.#
|
|
2408
|
+
this.#setResult(replaceAt(this.#result, index, result));
|
|
2388
2409
|
this.#notify();
|
|
2389
2410
|
}
|
|
2390
2411
|
}
|