0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
query/examples/angular/rxjs
Wonsuk Choi cb62f4f2ed
chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors (#12555)
* chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors

* chore(pnpm-lock.yaml): run 'pnpm dedupe'

* chore(scripts): move 'oxlint/plugin.ts' to 'oxlint-plugin.ts' to match the flat layout of 'scripts'

* chore(pnpm-workspace.yaml): update '@typescript-eslint/parser' and '@typescript-eslint/rule-tester' to '^8.72.1' to match the deduped '@typescript-eslint/utils'
History 2026-11-16 22:25:25 +09:00
..
.devcontainer chore(angular-query): update example dev containers to node 22 (#8370) 2024-11-28 17:24:46 +01:00
public docs(examples): use the TanStack Query emblem as the favicon in every example (#12578) 2026-11-12 13:33:29 +09:00
src chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors (#12555) 2026-11-16 22:25:25 +09:00
.gitignore docs(examples): use each framework's template '.gitignore' in every example (#12592) 2026-11-13 10:57:29 +09:00
angular.json docs(examples): use the TanStack Query emblem as the favicon in every example (#12578) 2026-11-12 13:33:29 +09:00
eslint.config.js chore(examples/*/eslint.config): use 'flat/recommended-strict' from '@tanstack/eslint-plugin-query' (#12385) 2026-10-26 02:55:51 +09:00
package.json ci: Version Packages (#12543) 2026-11-07 00:00:45 +01:00
README.md docs(examples/angular): align 'angular.json', root components, 'OnPush', mock interceptors and 'tsconfig' across the examples (#12593) 2026-11-14 02:55:47 +09:00
tsconfig.app.json docs(angular-query): add rxjs example (#8108) 2024-09-29 00:37:01 +02:00
tsconfig.json chore(examples/*/tsconfig): include '*.config.ts' and '*.config.js' like the packages (#12408) 2026-10-27 09:11:08 +09:00

TanStack Angular Query RxJS Example

An autocomplete that debounces input with RxJS and keeps the previous results with keepPreviousData.

How it works

  • src/app/services/suggestions/queries.ts is an @Injectable SuggestionsQueries whose list(term) returns queryOptions keyed by ['suggestions', 'list', term]. src/app/services/suggestions/api.ts returns an empty list for a blank term without making a request.
  • src/app/components/example.component.ts pipes the form control's valueChanges through debounceTime(300) and distinctUntilChanged(), and turns the result into the term signal with toSignal.
  • src/app/components/example.component.ts then spreads list(this.term()) into injectQuery with placeholderData: keepPreviousData and a 5-minute staleTime, so the previous suggestions stay on screen while the next term loads.
  • src/app/interceptor/autocomplete-mock.interceptor.ts is an HttpInterceptorFn, registered with withInterceptors in src/app/app.config.ts, that answers /api/autocomplete with the programming languages starting with the term after 100 to 500 ms.

To run this example:

  • npm install
  • npm start