From 4e13e5d8b1d7057cf5c2b94999129beea9470b55 Mon Sep 17 00:00:00 2001 From: Arnoud de Vries <6420061+arnoud-dv@users.noreply.github.com> Date: Fri, 12 Sep 2025 16:55:26 +0200 Subject: [PATCH] docs(angular-query): improve mutationOptions jsdoc code example --- .../src/mutation-options.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/angular-query-experimental/src/mutation-options.ts b/packages/angular-query-experimental/src/mutation-options.ts index eaac0c5f85..61dfc242cb 100644 --- a/packages/angular-query-experimental/src/mutation-options.ts +++ b/packages/angular-query-experimental/src/mutation-options.ts @@ -16,17 +16,21 @@ import type { CreateMutationOptions } from './types' * mutationKey: ["updatePost", id], * onSuccess: (newPost) => { * // ^? newPost: Post - * this.queryClient.setQueryData(["posts", id], newPost); + * this.queryClient.setQueryData(["posts", id], newPost) * }, * }); * } * } * - * queries = inject(QueriesService) - * idSignal = new Signal(0); - * mutation = injectMutation(() => this.queries.updatePost(this.idSignal())) + * class ComponentOrService { + * queries = inject(QueriesService) + * id = signal(0) + * mutation = injectMutation(() => this.queries.updatePost(this.id())) + * } * - * mutation.mutate({ title: 'New Title' }) + * save() { + * this.mutation.mutate({ title: 'New Title' }) + * } * ``` * @param options - The mutation options. * @returns Mutation options. @@ -75,17 +79,21 @@ export function mutationOptions< * mutationKey: ["updatePost", id], * onSuccess: (newPost) => { * // ^? newPost: Post - * this.queryClient.setQueryData(["posts", id], newPost); + * this.queryClient.setQueryData(["posts", id], newPost) * }, * }); * } * } * - * queries = inject(QueriesService) - * idSignal = new Signal(0); - * mutation = injectMutation(() => this.queries.updatePost(this.idSignal())) + * class ComponentOrService { + * queries = inject(QueriesService) + * id = signal(0) + * mutation = injectMutation(() => this.queries.updatePost(this.id())) + * } * - * mutation.mutate({ title: 'New Title' }) + * save() { + * this.mutation.mutate({ title: 'New Title' }) + * } * ``` * @param options - The mutation options. * @returns Mutation options.