You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/angular/angular-httpclient-and-other-data-fetching-clients.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Because TanStack Query's fetching mechanisms are agnostically built on Promises,
12
12
- Mock responses in unit tests using [provideHttpClientTesting](https://angular.dev/guide/http/testing).
13
13
-[Interceptors](https://angular.dev/guide/http/interceptors) can be used for a wide range of functionality including adding authentication headers, performing logging, etc. While some data fetching libraries have their own interceptor system, `HttpClient` interceptors are integrated with Angular's dependency injection system.
14
14
-`HttpClient` automatically informs [`PendingTasks`](https://angular.dev/api/core/PendingTasks#), which enables Angular to be aware of pending requests. Unit tests and SSR can use the resulting application _stableness_ information to wait for pending requests to finish. This makes unit testing much easier for [Zoneless](https://angular.dev/guide/zoneless) applications.
15
-
- When using SSR, `HttpClient` will [cache requests](https://angular.dev/guide/ssr#caching-data-when-using-HttpClient) performed on the server. This will prevent unneeded requests on the client. `HttpClient` SSR caching works out of the box. TanStack Query has its own hydration functionality which may be more powerful but requires some setup. Which one fits your needs best depends on your use case.
15
+
- When using SSR, `HttpClient` will [cache requests](https://angular.dev/guide/ssr#caching-data-when-using-HttpClient) performed on the server. TanStack Query will additionally [hydrate its cache](./guides/ssr.md) from the server-rendered HTML when you use `provideTanStackQuery`.
16
16
17
17
### Using observables in `queryFn`
18
18
@@ -36,8 +36,6 @@ class ExampleComponent {
36
36
```
37
37
38
38
> Since Angular is moving towards RxJS as an optional dependency, it's expected that `HttpClient` will also support promises in the future.
39
-
>
40
-
> Support for observables in TanStack Query for Angular is planned.
Copy file name to clipboardExpand all lines: docs/framework/angular/devtools.md
+39-35Lines changed: 39 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,17 +11,23 @@ title: Devtools
11
11
12
12
## Enable devtools
13
13
14
+
Add the devtools package (in addition to `@tanstack/angular-query-experimental`):
15
+
16
+
```bash
17
+
npm install @tanstack/angular-query-devtools
18
+
```
19
+
14
20
The devtools help you debug and inspect your queries and mutations. You can enable the devtools by adding `withDevtools` to `provideTanStackQuery`.
15
21
16
-
By default, Angular Query Devtools are only included in development mode bundles, so you don't need to worry about excluding them during a production build.
22
+
By default, Angular Query Devtools only load in development.
Devtools are automatically excluded from production builds. However, it might be desirable to lazy load the devtools in production.
34
-
35
-
To use `withDevtools` in production builds, import using the `production` sub-path. The function exported from the production subpath is identical to the main one, but won't be excluded from production builds.
39
+
If you need the real implementation in production, import from the `production` entrypoint.
When setting the option to false, the devtools will not be loaded.
73
81
74
82
```ts
75
-
provideTanStackQuery(
76
-
newQueryClient(),
77
-
withDevtools(() => ({ loadDevtools: false })),
78
-
)
83
+
providers: [
84
+
provideTanStackQuery(
85
+
newQueryClient(),
86
+
withDevtools(() => ({ loadDevtools: false })),
87
+
),
88
+
]
79
89
```
80
90
81
91
## Derive options through reactivity
82
92
83
-
Options are passed to `withDevtools` from a callback function to support reactivity through signals. In the following example
84
-
a signal is created from a RxJS observable that emits on a keyboard shortcut. When the derived signal is set to true, the devtools are lazily loaded.
85
-
86
-
The example below always loads devtools in development mode and loads on-demand in production mode when a keyboard shortcut is pressed.
93
+
Options can be returned from a callback so they can react to signals. For example, a signal derived from a keyboard shortcut can enable devtools on demand:
@@ -107,14 +114,12 @@ export class DevtoolsOptionsManager {
107
114
}
108
115
```
109
116
110
-
If you want to use an injectable such as a service in the callback you can use `deps`. The injected value will be passed as parameter to the callback function.
111
-
112
-
This is similar to `deps` in Angular's [`useFactory`](https://angular.dev/guide/di/dependency-injection-providers#factory-providers-usefactory) provider.
117
+
To use an injectable such as a service in the callback, pass it through `deps`:
113
118
114
119
```ts
115
120
// ...
116
121
// 👇 Note we import from the production sub-path to enable devtools lazy loading in production builds
Copy file name to clipboardExpand all lines: docs/framework/angular/guides/caching.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,9 @@ Let's assume we are using the default `gcTime` of **5 minutes** and the default
27
27
- When the request completes successfully, the cache's data under the `['todos']` key is updated with the new data, and both instances are updated with the new data.
28
28
- Both instances of the `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos }))` query are destroyed and no longer in use.
29
29
- Since there are no more active instances of this query, a garbage collection timeout is set using `gcTime` to delete and garbage collect the query (defaults to **5 minutes**).
30
-
- Before the cache timeout has completed, another instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos }))` mounts. The query immediately returns the available cached data while the `fetchTodos` function is being run in the background. When it completes successfully, it will populate the cache with fresh data.
31
-
- The final instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos }))` gets destroyed.
32
-
- No more instances of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos }))` appear within **5 minutes**.
30
+
- Before the cache timeout has completed, another instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` mounts. The query immediately returns the available cached data while the `fetchTodos` function is being run in the background. When it completes successfully, it will populate the cache with fresh data.
31
+
- The final instance of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` gets destroyed.
32
+
- No more instances of `injectQuery(() => ({ queryKey: ['todos'], queryFn: fetchTodos })` appear within **5 minutes**.
33
33
- The cached data under the `['todos']` key is deleted and garbage collected.
34
34
35
35
For more advanced use-cases, see [injectQuery](../reference/functions/injectQuery.md).
0 commit comments