Open History to see the last commit
1import { Injectable, inject } from '@angular/core'
2import { queryOptions } from '@tanstack/angular-query-experimental'
3import { lastValueFrom } from 'rxjs'
4import { SuggestionsAPI } from './api'
5β
6@Injectable({
7 providedIn: 'root',
8})
9export class SuggestionsQueries {
10 readonly #api = inject(SuggestionsAPI)
11β
12 all = () => ['suggestions'] as const
13β
14 list = (term: string) =>
15 queryOptions({
16 queryKey: [...this.all(), 'list', term] as const,
17 queryFn: () => lastValueFrom(this.#api.getSuggestions(term)),
18 })
19}