snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "Node.js",
|
||||
"image": "mcr.microsoft.com/devcontainers/javascript-node:22"
|
||||
}
|
||||
6
examples/angular/devtools-panel/README.md
Normal file
6
examples/angular/devtools-panel/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# TanStack Query Angular devtools panel example
|
||||
|
||||
To run this example:
|
||||
|
||||
- `pnpm install`
|
||||
- `pnpm start`
|
||||
128
examples/angular/devtools-panel/angular.json
Normal file
128
examples/angular/devtools-panel/angular.json
Normal file
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"cli": {
|
||||
"packageManager": "pnpm",
|
||||
"analytics": false,
|
||||
"cache": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"devtools-panel": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"inlineTemplate": true,
|
||||
"inlineStyle": true,
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:class": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:guard": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:interceptor": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:pipe": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:resolver": {
|
||||
"skipTests": true
|
||||
},
|
||||
"@schematics/angular:service": {
|
||||
"skipTests": true
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular/build:application",
|
||||
"options": {
|
||||
"outputPath": "dist/devtools-panel",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular/build:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "devtools-panel:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "devtools-panel:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular/build:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "devtools-panel:build"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"type": "component"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"type": "directive"
|
||||
},
|
||||
"@schematics/angular:service": {
|
||||
"type": "service"
|
||||
},
|
||||
"@schematics/angular:guard": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:interceptor": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:module": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:pipe": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:resolver": {
|
||||
"typeSeparator": "."
|
||||
}
|
||||
}
|
||||
}
|
||||
28
examples/angular/devtools-panel/package.json
Normal file
28
examples/angular/devtools-panel/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@tanstack/query-example-angular-devtools-panel",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/common": "^20.0.0",
|
||||
"@angular/compiler": "^20.0.0",
|
||||
"@angular/core": "^20.0.0",
|
||||
"@angular/platform-browser": "^20.0.0",
|
||||
"@angular/router": "^20.0.0",
|
||||
"@tanstack/angular-query-experimental": "^5.102.8",
|
||||
"rxjs": "^7.8.2",
|
||||
"tslib": "^2.8.1",
|
||||
"zone.js": "0.15.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/build": "^20.0.0",
|
||||
"@angular/cli": "^20.0.0",
|
||||
"@angular/compiler-cli": "^20.0.0",
|
||||
"typescript": "5.8.3"
|
||||
}
|
||||
}
|
||||
21
examples/angular/devtools-panel/src/app/app.component.ts
Normal file
21
examples/angular/devtools-panel/src/app/app.component.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core'
|
||||
import { RouterLink, RouterOutlet } from '@angular/router'
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<ul>
|
||||
<li>
|
||||
<a routerLink="basic">Basic devtools panel example</a>
|
||||
</li>
|
||||
<li>
|
||||
<a routerLink="lazy">Lazy load devtools panel example</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<router-outlet />
|
||||
`,
|
||||
imports: [RouterOutlet, RouterLink],
|
||||
})
|
||||
export class AppComponent {}
|
||||
17
examples/angular/devtools-panel/src/app/app.config.ts
Normal file
17
examples/angular/devtools-panel/src/app/app.config.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { provideHttpClient, withFetch } from '@angular/common/http'
|
||||
|
||||
import { provideRouter } from '@angular/router'
|
||||
import {
|
||||
QueryClient,
|
||||
provideTanStackQuery,
|
||||
} from '@tanstack/angular-query-experimental'
|
||||
import { routes } from './app.routes'
|
||||
import type { ApplicationConfig } from '@angular/core'
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideHttpClient(withFetch()),
|
||||
provideRouter(routes),
|
||||
provideTanStackQuery(new QueryClient()),
|
||||
],
|
||||
}
|
||||
19
examples/angular/devtools-panel/src/app/app.routes.ts
Normal file
19
examples/angular/devtools-panel/src/app/app.routes.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Route } from '@angular/router'
|
||||
|
||||
export const routes: Array<Route> = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'basic',
|
||||
pathMatch: 'full',
|
||||
},
|
||||
{
|
||||
path: 'basic',
|
||||
loadComponent: () =>
|
||||
import('./components/basic-devtools-panel-example.component'),
|
||||
},
|
||||
{
|
||||
path: 'lazy',
|
||||
loadComponent: () =>
|
||||
import('./components/lazy-load-devtools-panel-example.component'),
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
signal,
|
||||
viewChild,
|
||||
} from '@angular/core'
|
||||
import { injectDevtoolsPanel } from '@tanstack/angular-query-experimental/devtools-panel'
|
||||
import { ExampleQueryComponent } from './example-query.component'
|
||||
import type { ElementRef } from '@angular/core'
|
||||
|
||||
@Component({
|
||||
selector: 'basic-devtools-panel-example',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
<example-query />
|
||||
<h1>Basic devtools panel example</h1>
|
||||
<p>
|
||||
In this example, the devtools panel is loaded programmatically when the
|
||||
button is clicked
|
||||
</p>
|
||||
<button type="button" (click)="toggleIsOpen()">
|
||||
{{ isOpen() ? 'Close' : 'Open' }} the devtools panel
|
||||
</button>
|
||||
@if (isOpen()) {
|
||||
<div #div style="height: 500px"></div>
|
||||
}
|
||||
`,
|
||||
imports: [ExampleQueryComponent],
|
||||
})
|
||||
export default class BasicDevtoolsPanelExampleComponent {
|
||||
readonly isOpen = signal(false)
|
||||
readonly divEl = viewChild<ElementRef>('div')
|
||||
|
||||
toggleIsOpen() {
|
||||
this.isOpen.update((prev) => !prev)
|
||||
}
|
||||
|
||||
readonly devtools = injectDevtoolsPanel(() => ({
|
||||
hostElement: this.divEl(),
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
|
||||
import { injectQuery } from '@tanstack/angular-query-experimental'
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { lastValueFrom } from 'rxjs'
|
||||
|
||||
interface Response {
|
||||
name: string
|
||||
description: string
|
||||
subscribers_count: number
|
||||
stargazers_count: number
|
||||
forks_count: number
|
||||
}
|
||||
|
||||
@Component({
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
selector: 'example-query',
|
||||
template: `
|
||||
<div style="padding-bottom: 20px">
|
||||
@if (query.isPending()) {
|
||||
<div>Loading...</div>
|
||||
}
|
||||
@if (query.isError()) {
|
||||
<div>An error has occurred: {{ query.error().message }}</div>
|
||||
}
|
||||
@if (query.isSuccess()) {
|
||||
@let data = query.data();
|
||||
<h1>{{ data.name }}</h1>
|
||||
<p>{{ data.description }}</p>
|
||||
<strong>👀 {{ data.subscribers_count }}</strong>
|
||||
<strong>✨ {{ data.stargazers_count }}</strong>
|
||||
<strong>🍴 {{ data.forks_count }}</strong>
|
||||
}
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
export class ExampleQueryComponent {
|
||||
readonly #http = inject(HttpClient)
|
||||
|
||||
readonly query = injectQuery(() => ({
|
||||
queryKey: ['repoData'],
|
||||
queryFn: () =>
|
||||
lastValueFrom(
|
||||
this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),
|
||||
),
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
Injector,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
signal,
|
||||
viewChild,
|
||||
} from '@angular/core'
|
||||
import { ExampleQueryComponent } from './example-query.component'
|
||||
import type { ElementRef } from '@angular/core'
|
||||
import type { DevtoolsPanelRef } from '@tanstack/angular-query-experimental/devtools-panel'
|
||||
|
||||
@Component({
|
||||
selector: 'lazy-load-devtools-panel-example',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
template: `
|
||||
<example-query />
|
||||
<h1>Lazy load devtools panel example</h1>
|
||||
<p>
|
||||
In this example, the devtools panel is loaded programmatically when the
|
||||
button is clicked. In addition, the code is lazy loaded.
|
||||
</p>
|
||||
<button type="button" (click)="toggleIsOpen()">
|
||||
{{ isOpen() ? 'Close' : 'Open' }} the devtools panel
|
||||
</button>
|
||||
@if (isOpen()) {
|
||||
<div #div style="height: 500px"></div>
|
||||
}
|
||||
`,
|
||||
imports: [ExampleQueryComponent],
|
||||
})
|
||||
export default class LazyLoadDevtoolsPanelExampleComponent {
|
||||
readonly isOpen = signal(false)
|
||||
readonly devtools = signal<Promise<DevtoolsPanelRef> | undefined>(undefined)
|
||||
readonly injector = inject(Injector)
|
||||
|
||||
readonly divEl = viewChild<ElementRef>('div')
|
||||
readonly devToolsOptions = computed(() => ({
|
||||
hostElement: this.divEl(),
|
||||
}))
|
||||
|
||||
toggleIsOpen() {
|
||||
this.isOpen.update((prev) => !prev)
|
||||
}
|
||||
|
||||
readonly loadDevtoolsEffect = effect(() => {
|
||||
if (this.devtools()) return
|
||||
if (this.isOpen()) {
|
||||
this.devtools.set(
|
||||
import('@tanstack/angular-query-experimental/devtools-panel').then(
|
||||
({ injectDevtoolsPanel }) =>
|
||||
injectDevtoolsPanel(this.devToolsOptions, {
|
||||
injector: this.injector,
|
||||
}),
|
||||
),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
BIN
examples/angular/devtools-panel/src/favicon.ico
Normal file
BIN
examples/angular/devtools-panel/src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
13
examples/angular/devtools-panel/src/index.html
Normal file
13
examples/angular/devtools-panel/src/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>TanStack Query devtools panel example</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
5
examples/angular/devtools-panel/src/main.ts
Normal file
5
examples/angular/devtools-panel/src/main.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser'
|
||||
import { appConfig } from './app/app.config'
|
||||
import { AppComponent } from './app/app.component'
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err))
|
||||
10
examples/angular/devtools-panel/tsconfig.app.json
Normal file
10
examples/angular/devtools-panel/tsconfig.app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": ["src/main.ts"],
|
||||
"include": ["src/**/*.d.ts"]
|
||||
}
|
||||
31
examples/angular/devtools-panel/tsconfig.json
Normal file
31
examples/angular/devtools-panel/tsconfig.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"skipLibCheck": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "Bundler",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"useDefineForClassFields": false,
|
||||
"lib": ["ES2022", "dom"]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictStandalone": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user