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/devtools.md
+77-37Lines changed: 77 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,62 +3,102 @@ id: devtools
3
3
title: Devtools
4
4
---
5
5
6
-
## Install and Import the Devtools
6
+
## Enable devtools
7
7
8
-
The devtools are a separate package that you need to install:
8
+
The devtools help you debug and inspect your queries and mutations. You can enable the devtools by adding `withDevtools`to `provideTanStackQuery`.
9
9
10
-
```bash
11
-
npm i @tanstack/angular-query-devtools-experimental
12
-
```
13
-
14
-
or
10
+
By default, the devtools are enabled when Angular [`isDevMode`](https://angular.dev/api/core/isDevMode) returns true. So you don't need to worry about excluding them during a production build. The core tools are lazily loaded and excluded from bundled code. In most cases, all you'll need to do is add `withDevtools()` to `provideTanStackQuery` without any additional configuration.
If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.
27
+
28
+
When not setting the option or setting it to 'auto', the devtools will be loaded when Angular is in development mode.
When setting the option to false, the devtools will not be loaded.
39
50
40
-
Floating Mode will mount the devtools as a fixed, floating element in your app and provide a toggle in the corner of the screen to show and hide the devtools. This toggle state will be stored and remembered in localStorage across reloads.
41
-
42
-
Place the following code as high in your Angular app as you can. The closer it is to the root of the page, the better it will work!
51
+
```ts
52
+
provideTanStackQuery(
53
+
newQueryClient(),
54
+
withDevtools(() => ({ loadDevtools: false })),
55
+
)
56
+
```
43
57
44
-
```angular-ts
45
-
import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimental'
46
-
import { Component } from '@angular/core';
58
+
The `withDevtools` options are returned from a callback function to support reactivity through signals. In the following example
59
+
a signal is created from a RxJS observable that listens for a keyboard shortcut. When the event is triggered, the devtools are lazily loaded.
60
+
Using this technique allows you to support on-demand loading of the devtools even in production mode, without including the full tools in the bundled code.
- Use this to predefine some errors that can be triggered on your queries. Initializer will be called (with the specific query) when that error is toggled on from the UI. It must return an Error.
73
113
-`styleNonce?: string`
74
114
- Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
Copy file name to clipboardExpand all lines: docs/framework/angular/overview.md
+9-13Lines changed: 9 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,11 @@ The `@tanstack/angular-query-experimental` package offers a 1st-class API for us
9
9
10
10
## Feedback welcome!
11
11
12
-
We are in the process of getting to a stable API for Angular Query. If you have any feedback, please contact us at the [TanStack Discord](https://tlinz.com/discord) server or [visit this discussion](https://github.com/TanStack/query/discussions/6293) on Github.
12
+
We are in the process of getting to a stable API for TanStack Query on Angular. If you have any feedback, please contact us at the [TanStack Discord](https://tlinz.com/discord) server or [visit this discussion](https://github.com/TanStack/query/discussions/6293) on Github.
13
13
14
14
## Supported Angular Versions
15
15
16
-
Angular Query is compatible with Angular v16 and higher.
16
+
TanStack Query is compatible with Angular v16 and higher.
17
17
18
18
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes **fetching, caching, synchronizing and updating server state** in your web applications a breeze.
19
19
@@ -41,11 +41,11 @@ Once you grasp the nature of server state in your application, **even more chall
41
41
42
42
If you're not overwhelmed by that list, then that must mean that you've probably solved all of your server state problems already and deserve an award. However, if you are like a vast majority of people, you either have yet to tackle all or most of these challenges and we're only scratching the surface!
43
43
44
-
Angular Query is hands down one of the _best_ libraries for managing server state. It works amazingly well **out-of-the-box, with zero-config, and can be customized** to your liking as your application grows.
44
+
TanStack Query is hands down one of the _best_ libraries for managing server state. It works amazingly well **out-of-the-box, with zero-config, and can be customized** to your liking as your application grows.
45
45
46
-
Angular Query allows you to defeat and overcome the tricky challenges and hurdles of _server state_ and control your app data before it starts to control you.
46
+
TanStack Query allows you to defeat and overcome the tricky challenges and hurdles of _server state_ and control your app data before it starts to control you.
47
47
48
-
On a more technical note, Angular Query will likely:
48
+
On a more technical note, TanStack Query will likely:
49
49
50
50
- Help you remove **many** lines of complicated and misunderstood code from your application and replace with just a handful of lines of Angular Query logic.
51
51
- Make your application more maintainable and easier to build new features without worrying about wiring up new server state data sources
@@ -56,12 +56,11 @@ On a more technical note, Angular Query will likely:
56
56
57
57
## Enough talk, show me some code already!
58
58
59
-
In the example below, you can see Angular Query in its most basic and simple form being used to fetch the GitHub stats for the TanStack Query GitHub project itself:
59
+
In the example below, you can see TanStack Query in its most basic and simple form being used to fetch the GitHub stats for the TanStack Query GitHub project itself:
60
60
61
61
[Open in StackBlitz](https://stackblitz.com/github/TanStack/query/tree/main/examples/angular/simple)
62
62
63
63
```angular-ts
64
-
import { AngularQueryDevtools } from '@tanstack/angular-query-devtools-experimental'
65
64
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
66
65
import { HttpClient } from '@angular/common/http'
67
66
import { CommonModule } from '@angular/common'
@@ -86,10 +85,7 @@ import { lastValueFrom } from 'rxjs'
86
85
<strong>✨ {{ data.stargazers_count }}</strong>
87
86
<strong>🍴 {{ data.forks_count }}</strong>
88
87
}
89
-
90
-
<angular-query-devtools initialIsOpen />
91
-
`,
92
-
imports: [AngularQueryDevtools],
88
+
`
93
89
})
94
90
export class SimpleExampleComponent {
95
91
http = inject(HttpClient)
@@ -103,7 +99,7 @@ export class SimpleExampleComponent {
103
99
}))
104
100
}
105
101
106
-
type Response = {
102
+
interface Response {
107
103
name: string
108
104
description: string
109
105
subscribers_count: number
@@ -114,4 +110,4 @@ type Response = {
114
110
115
111
## You talked me into it, so what now?
116
112
117
-
- Learn Angular Query at your own pace with our amazingly thorough [Walkthrough Guide](../installation) and [API Reference](../reference/functions/injectquery)
113
+
- Learn TanStack Query at your own pace with our amazingly thorough [Walkthrough Guide](../installation) and [API Reference](../reference/functions/injectquery)
0 commit comments