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

queries.ts

19 lines515 Bytes

1import { Injectable, inject } from '@angular/core'
2import { queryOptions } from '@tanstack/angular-query-experimental'
3import { lastValueFrom } from 'rxjs'
4import { ProjectsAPI } from './api'
5​
6@Injectable({
7 providedIn: 'root',
8})
9export class ProjectsQueries {
10 readonly #api = inject(ProjectsAPI)
11​
12 all = () => ['projects'] as const
13​
14 list = (page: number) =>
15 queryOptions({
16 queryKey: [...this.all(), 'list', page] as const,
17 queryFn: () => lastValueFrom(this.#api.getProjects(page)),
18 })