Skip to content

Commit 94ee0eb

Browse files
authored
docs(angular-query): improve mutationOptions jsdoc code example (#9648)
1 parent e3b40d4 commit 94ee0eb

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

packages/angular-query-experimental/src/mutation-options.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@ import type { CreateMutationOptions } from './types'
1616
* mutationKey: ["updatePost", id],
1717
* onSuccess: (newPost) => {
1818
* // ^? newPost: Post
19-
* this.queryClient.setQueryData(["posts", id], newPost);
19+
* this.queryClient.setQueryData(["posts", id], newPost)
2020
* },
2121
* });
2222
* }
2323
* }
2424
*
25-
* queries = inject(QueriesService)
26-
* idSignal = new Signal(0);
27-
* mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))
25+
* class ComponentOrService {
26+
* queries = inject(QueriesService)
27+
* id = signal(0)
28+
* mutation = injectMutation(() => this.queries.updatePost(this.id()))
29+
* }
2830
*
29-
* mutation.mutate({ title: 'New Title' })
31+
* save() {
32+
* this.mutation.mutate({ title: 'New Title' })
33+
* }
3034
* ```
3135
* @param options - The mutation options.
3236
* @returns Mutation options.
@@ -75,17 +79,21 @@ export function mutationOptions<
7579
* mutationKey: ["updatePost", id],
7680
* onSuccess: (newPost) => {
7781
* // ^? newPost: Post
78-
* this.queryClient.setQueryData(["posts", id], newPost);
82+
* this.queryClient.setQueryData(["posts", id], newPost)
7983
* },
8084
* });
8185
* }
8286
* }
8387
*
84-
* queries = inject(QueriesService)
85-
* idSignal = new Signal(0);
86-
* mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))
88+
* class ComponentOrService {
89+
* queries = inject(QueriesService)
90+
* id = signal(0)
91+
* mutation = injectMutation(() => this.queries.updatePost(this.id()))
92+
* }
8793
*
88-
* mutation.mutate({ title: 'New Title' })
94+
* save() {
95+
* this.mutation.mutate({ title: 'New Title' })
96+
* }
8997
* ```
9098
* @param options - The mutation options.
9199
* @returns Mutation options.

0 commit comments

Comments
 (0)