Skip to content

Commit

Permalink
feat: add mutation retries
Browse files Browse the repository at this point in the history
  • Loading branch information
edbzn committed Jan 3, 2024
1 parent 35e0c95 commit 0b61f5a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions projects/todo-mvc/src/app/todo.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@ export class TodoResource {
addOne = injectMutation(() => ({
mutationFn: (todo: Pick<Todo, 'text'>) =>
lastValueFrom(this.#http.post<Todo[]>(TodoResource.endpoint, todo)),
retry: 5,
}));

removeOne = injectMutation(() => ({
mutationFn: (todo: Pick<Todo, 'id'>) =>
lastValueFrom(
this.#http.delete<Todo[]>(`${TodoResource.endpoint}/${todo.id}`)
),
retry: 5,
}));

updateOne = injectMutation(() => ({
mutationFn: (todo: Todo) =>
lastValueFrom(
this.#http.put<Todo[]>(`${TodoResource.endpoint}/${todo.id}`, todo)
),
retry: 5,
}));

updateMany = injectMutation(() => ({
mutationFn: (todos: Todo[]) =>
lastValueFrom(this.#http.put<Todo[]>(`${TodoResource.endpoint}`, todos)),
retry: 5,
}));
}

0 comments on commit 0b61f5a

Please sign in to comment.