| 15 | templateUrl: './post.component.html', |
| 16 | }) |
| 17 | export class PostComponent { |
| 18 | readonly #postsService = inject(PostsService) |
| 19 | |
| 20 | readonly setPostId = output<number>() |
| 21 | readonly postId = input(0) |
| 22 | |
| 23 | readonly postQuery = injectQuery(() => ({ |
| 24 | enabled: this.postId() > 0, |
| 25 | queryKey: ['post', this.postId()], |
| 26 | queryFn: (context) => { |
| 27 | // Cancels the request when component is destroyed before the request finishes |
| 28 | const abort$ = fromEvent(context.signal, 'abort') |
| 29 | return lastValueFrom( |
| 30 | this.#postsService.postById$(this.postId()).pipe(takeUntil(abort$)), |
| 31 | ) |
| 32 | }, |
| 33 | })) |
| 34 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…