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
+56-17Lines changed: 56 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -7,27 +7,38 @@ title: Devtools
7
7
8
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
-
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.
10
+
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.
Devtools are automatically excluded from production builds. However, it might be desirable to lazy load the devtools in production.
28
+
29
+
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.
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.
35
+
To control when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations or user interaction. For instance, you might have a test environment running in production mode but still require devtools to be available.
27
36
28
-
When not setting the option or setting it to 'auto', the devtools will be loaded when Angular is in development mode.
37
+
When not setting the option or setting it to 'auto', the devtools will be loaded automatically when Angular runs in development mode.
When setting the option to true, the devtools will be loaded in both development and production mode.
41
52
53
+
This is particularly useful if you want to load devtools based on environment configurations. E.g. you could set this to true either when `isDevMode()` is true or when the application is running on your production build staging environment.
54
+
42
55
```ts
56
+
// Make sure to use the production sub-path to load devtools in production builds
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.
74
+
## Derive options through reactivity
75
+
76
+
Options are passed to `withDevtools` from a callback function to support reactivity through signals. In the following example
77
+
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.
78
+
79
+
> If you don't need devtools in production builds, don't use the `production` sub-path. Even though most of the devtools are lazy loaded on-demand, code is needed for on-demand loading and option handling. When importing devtools from `@tanstack/angular-query-experimental/devtools`, all devtools code will be excluded from your build and no lazy chunks will be created, minimizing deployment size.
80
+
81
+
The example below always loads devtools in development mode and loads on-demand in production mode when a keyboard shortcut is pressed.
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.
106
+
107
+
This is similar to `deps` in Angular's [`useFactory`](https://angular.dev/guide/di/dependency-injection-providers#factory-providers-usefactory) provider.
0 commit comments