Open History to see the last commit
1# TanStack Angular Query Dynamic Devtools Example
2β
3Loads the devtools on demand in a production build with a keyboard shortcut.
4β
5## How it works
6β
7- `src/app/devtools-options.manager.ts` is an `@Injectable` `DevtoolsOptionsManager` whose `loadDevtools` signal becomes `true` the first time <kbd>β</kbd> <kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>D</kbd> is pressed. It is built with `fromEvent`, `scan` and `toSignal`.
8- `src/app/app.config.ts` imports `withDevtools` from `@tanstack/angular-query-devtools/production`, so the devtools are also available in production builds, and passes the signal as the `loadDevtools` option in an options function that can call `inject`.
9- `src/app/components/dynamic-devtools-example.component.ts` reads the `TanStack/query` repository with `injectQuery`, `HttpClient` and `lastValueFrom`, so the devtools have a query to show.
10β
11To run this example:
12β
13- `npm install`
14- `npm start`
15β
16To try the shortcut in a production build, run `npm start -- --configuration production`.