Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

README.md

16 lines1006 Bytes

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`.