Skip to content

Commit

Permalink
docs: improve documentation (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale Nguyen authored Feb 5, 2024
1 parent d463ab8 commit fd598a3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ npm i @ngneat/query

[Stackblitz Example](https://stackblitz.com/edit/stackblitz-starters-bsrgez?file=src%2Fmain.ts)

>Please be aware that the `@tanstack/query-core` package must also be installed for the functionality to operate correctly.
## Query Client

Inject the `QueryClient` [instance](https://tanstack.com/query/v5/docs/reference/QueryClient) through the `injectQueryClient()`
Expand Down Expand Up @@ -76,7 +78,7 @@ export class TodosService {
return this.#query({
queryKey: ['todos'] as const,
queryFn: () => {
return this.http.get<Todo[]>(
return this.#http.get<Todo[]>(
'https://jsonplaceholder.typicode.com/todos',
);
},
Expand Down Expand Up @@ -166,7 +168,7 @@ export class GroupsService {

groupOptions = queryOptions({
queryKey: ['groups'] as const,
queryFn: () => this.http.get(url),
queryFn: () => this.#http.get(url),
staleTime: 5 * 1000,
});

Expand Down Expand Up @@ -213,12 +215,12 @@ import { injectMutation } from '@ngneat/query';
@Injectable({ providedIn: 'root' })
export class TodosService {
#mutation = injectMutation();
#httpClient = inject(HttpClient);
#http = inject(HttpClient);

addTodo() {
return this.#mutation({
mutationFn: ({ title }) =>
this.http.post<Todo>(`https://jsonplaceholder.typicode.com/todos`, {
this.#http.post<Todo>(`https://jsonplaceholder.typicode.com/todos`, {
title,
}),
});
Expand Down

0 comments on commit fd598a3

Please sign in to comment.