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

queries.ts

19 lines481 Bytes

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