Open History to see the last commit
1import { Injectable, inject } from '@angular/core'
2import { infiniteQueryOptions } 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 = () =>
15 infiniteQueryOptions({
16 queryKey: [...this.all(), 'list'] as const,
17 queryFn: ({ pageParam }) =>
18 lastValueFrom(this.#api.getProjects(pageParam)),
19 initialPageParam: 0,
20 getPreviousPageParam: (firstPage) => firstPage.previousId ?? undefined,
21 getNextPageParam: (lastPage) => lastPage.nextId ?? undefined,
22 })
23}