mirror of
https://github.com/TanStack/query.git
synced 2026-11-16 22:50:20 +00:00
* 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
|
|
|---|---|---|
| .. | ||
| .devcontainer | ||
| public | ||
| src | ||
| .gitignore | ||
| angular.json | ||
| eslint.config.js | ||
| package.json | ||
| README.md | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
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.tsis an@InjectableSuggestionsQuerieswhoselist(term)returnsqueryOptionskeyed by['suggestions', 'list', term].src/app/services/suggestions/api.tsreturns an empty list for a blank term without making a request.src/app/components/example.component.tspipes the form control'svalueChangesthroughdebounceTime(300)anddistinctUntilChanged(), and turns the result into thetermsignal withtoSignal.src/app/components/example.component.tsthen spreadslist(this.term())intoinjectQuerywithplaceholderData: keepPreviousDataand a 5-minutestaleTime, so the previous suggestions stay on screen while the next term loads.src/app/interceptor/autocomplete-mock.interceptor.tsis anHttpInterceptorFn, registered withwithInterceptorsinsrc/app/app.config.ts, that answers/api/autocompletewith the programming languages starting with the term after 100 to 500 ms.
To run this example:
npm installnpm start