react-code-dataset / react-query /examples /angular /router /src /app /components /posts.component.ts
Download react-query/examples/angular/router/src/app/components/posts.component.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 726 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/router/src/app/components/posts.component.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/router/src/app/components/posts.component.ts
-
curl -L -o posts.component.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/router/src/app/components/posts.component.ts
726 Bytes
| import { ChangeDetectionStrategy, Component, inject } from '@angular/core' | |
| import { RouterLink } from '@angular/router' | |
| import { QueryClient, injectQuery } from '@tanstack/angular-query-experimental' | |
| import { lastValueFrom } from 'rxjs' | |
| import { PostsService } from '../services/posts-service' | |
| ({ | |
| changeDetection: ChangeDetectionStrategy.OnPush, | |
| selector: 'posts', | |
| templateUrl: './posts.component.html', | |
| imports: [RouterLink], | |
| }) | |
| export default class PostsComponent { | |
| readonly #postsService = inject(PostsService) | |
| readonly postsQuery = injectQuery(() => ({ | |
| queryKey: ['posts'], | |
| queryFn: () => lastValueFrom(this.#postsService.allPosts$()), | |
| })) | |
| readonly queryClient = inject(QueryClient) | |
| } | |