Skip to content

Commit 18915aa

Browse files
authored
Merge branch 'main' into chore/ts-async-lint-rules
2 parents f5da04c + 81aa02b commit 18915aa

File tree

14 files changed

+42
-44
lines changed

14 files changed

+42
-44
lines changed

examples/angular/auto-refetching/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

examples/angular/basic-persister/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"@tanstack/angular-query-persist-client": "^5.62.7",
1919
"@tanstack/query-sync-storage-persister": "^5.75.7",
2020
"rxjs": "^7.8.2",

examples/angular/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

examples/angular/devtools-panel/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
1717
"@angular/router": "^19.2.4",
18-
"@tanstack/angular-query-devtools-experimental": "^5.75.7",
19-
"@tanstack/angular-query-experimental": "^5.75.7",
18+
"@tanstack/angular-query-devtools-experimental": "^5.75.8",
19+
"@tanstack/angular-query-experimental": "^5.75.8",
2020
"rxjs": "^7.8.2",
2121
"tslib": "^2.8.1",
2222
"zone.js": "0.15.0"

examples/angular/infinite-query-with-max-pages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

examples/angular/optimistic-updates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@angular/forms": "^19.2.4",
1616
"@angular/platform-browser": "^19.2.4",
1717
"@angular/platform-browser-dynamic": "^19.2.4",
18-
"@tanstack/angular-query-experimental": "^5.75.7",
18+
"@tanstack/angular-query-experimental": "^5.75.8",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/pagination/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

examples/angular/query-options-from-a-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
1717
"@angular/router": "^19.2.4",
18-
"@tanstack/angular-query-experimental": "^5.75.7",
18+
"@tanstack/angular-query-experimental": "^5.75.8",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
1717
"@angular/router": "^19.2.4",
18-
"@tanstack/angular-query-experimental": "^5.75.7",
18+
"@tanstack/angular-query-experimental": "^5.75.8",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/rxjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@angular/forms": "^19.2.4",
1616
"@angular/platform-browser": "^19.2.4",
1717
"@angular/platform-browser-dynamic": "^19.2.4",
18-
"@tanstack/angular-query-experimental": "^5.75.7",
18+
"@tanstack/angular-query-experimental": "^5.75.8",
1919
"rxjs": "^7.8.2",
2020
"tslib": "^2.8.1",
2121
"zone.js": "0.15.0"

examples/angular/simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@angular/core": "^19.2.4",
1515
"@angular/platform-browser": "^19.2.4",
1616
"@angular/platform-browser-dynamic": "^19.2.4",
17-
"@tanstack/angular-query-experimental": "^5.75.7",
17+
"@tanstack/angular-query-experimental": "^5.75.8",
1818
"rxjs": "^7.8.2",
1919
"tslib": "^2.8.1",
2020
"zone.js": "0.15.0"

packages/angular-query-devtools-experimental/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/angular-query-devtools-experimental",
3-
"version": "5.75.7",
3+
"version": "5.75.8",
44
"description": "Developer tools to interact with and visualize the TanStack/angular-query cache",
55
"author": "Arnoud de Vries",
66
"license": "MIT",

packages/angular-query-experimental/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/angular-query-experimental",
3-
"version": "5.75.7",
3+
"version": "5.75.8",
44
"description": "Signals for managing, caching and syncing asynchronous and remote data in Angular",
55
"author": "Arnoud de Vries",
66
"license": "MIT",

packages/angular-query-experimental/src/providers.ts

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import {
66
computed,
77
effect,
88
inject,
9-
makeEnvironmentProviders,
109
} from '@angular/core'
1110
import { QueryClient, onlineManager } from '@tanstack/query-core'
1211
import { isPlatformBrowser } from '@angular/common'
1312
import { isDevMode } from './util/is-dev-mode/is-dev-mode'
1413
import { noop } from './util'
15-
import type { EnvironmentProviders, Provider } from '@angular/core'
14+
import type { Provider } from '@angular/core'
1615
import type {
1716
DevtoolsButtonPosition,
1817
DevtoolsErrorType,
@@ -23,9 +22,10 @@ import type {
2322
/**
2423
* Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
2524
* {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
26-
* for the entire application. You can use `provideQueryClient` to provide a
27-
* different `QueryClient` instance for a part of the application.
28-
* @param queryClient - the `QueryClient` instance to provide.
25+
* for the entire application. Internally it calls `provideQueryClient`.
26+
* You can use `provideQueryClient` to provide a different `QueryClient` instance for a part
27+
* of the application or for unit testing purposes.
28+
* @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
2929
* @returns a provider object that can be used to provide the `QueryClient` instance.
3030
*/
3131
export function provideQueryClient(
@@ -34,9 +34,14 @@ export function provideQueryClient(
3434
return {
3535
provide: QueryClient,
3636
useFactory: () => {
37-
return queryClient instanceof InjectionToken
38-
? inject(queryClient)
39-
: queryClient
37+
const client =
38+
queryClient instanceof InjectionToken
39+
? inject(queryClient)
40+
: queryClient
41+
// Unmount the query client on injector destroy
42+
inject(DestroyRef).onDestroy(() => client.unmount())
43+
client.mount()
44+
return client
4045
},
4146
}
4247
}
@@ -93,6 +98,17 @@ export function provideQueryClient(
9398
* }
9499
* )
95100
* ```
101+
*
102+
* **Example: using an InjectionToken**
103+
*
104+
* ```ts
105+
* export const MY_QUERY_CLIENT = new InjectionToken('', {
106+
* factory: () => new QueryClient(),
107+
* })
108+
*
109+
* // In a lazy loaded route or lazy loaded component's providers array:
110+
* providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
111+
* ```
96112
* @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
97113
* @param features - Optional features to configure additional Query functionality.
98114
* @returns A set of providers to set up TanStack Query.
@@ -102,27 +118,11 @@ export function provideQueryClient(
102118
export function provideTanStackQuery(
103119
queryClient: QueryClient | InjectionToken<QueryClient>,
104120
...features: Array<QueryFeatures>
105-
): EnvironmentProviders {
106-
return makeEnvironmentProviders([
121+
): Array<Provider> {
122+
return [
107123
provideQueryClient(queryClient),
108-
{
109-
// Do not use provideEnvironmentInitializer while Angular < v19 is supported
110-
provide: ENVIRONMENT_INITIALIZER,
111-
multi: true,
112-
useFactory: () => {
113-
const client =
114-
queryClient instanceof InjectionToken
115-
? inject(queryClient)
116-
: queryClient
117-
return () => {
118-
client.mount()
119-
// Unmount the query client on application destroy
120-
inject(DestroyRef).onDestroy(() => client.unmount())
121-
}
122-
},
123-
},
124124
features.map((feature) => feature.ɵproviders),
125-
])
125+
]
126126
}
127127

128128
/**
@@ -135,9 +135,7 @@ export function provideTanStackQuery(
135135
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
136136
* @deprecated Use `provideTanStackQuery` instead.
137137
*/
138-
export function provideAngularQuery(
139-
queryClient: QueryClient,
140-
): EnvironmentProviders {
138+
export function provideAngularQuery(queryClient: QueryClient): Array<Provider> {
141139
return provideTanStackQuery(queryClient)
142140
}
143141

0 commit comments

Comments
 (0)