Skip to content

Commit

Permalink
chore(playground): 🤖 merge changes from next into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
luii committed Nov 7, 2023
1 parent dbaddd6 commit 129b3b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Empty file.
13 changes: 12 additions & 1 deletion src/app/services/todos.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { injectMutation, injectQuery, toPromise } from '@ngneat/query';
import { injectMutation, injectQuery, queryOptions, toPromise } from '@ngneat/query';

interface Todo {
id: number;
Expand All @@ -13,6 +13,17 @@ export class TodosService {
private useMutation = injectMutation();
private http = inject(HttpClient);

todosQuery = queryOptions({
queryKey: ['todos'] as const,
queryFn: ({ signal }) => {
const source = this.http.get<Todo[]>(
'https://jsonplaceholder.typicode.com/todos'
);

return toPromise({ source, signal });
},
});

getTodos() {
return this.query({
queryKey: ['todos'] as const,
Expand Down

0 comments on commit 129b3b8

Please sign in to comment.