Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

MutationOptions

interfaz Since 1.2.0

Opciones de useRpcMutation y useApiMutation. Desde 1.2 los parámetros de tipo tipan los avisos onSuccess y onError; las firmas de los composables los rellenan.

ts
import type { MutationOptions } from "@meekojs/meeko/framework";

Source code src/app/runtime/mutations.ts:112

Declaración #

ts
interface MutationOptions<Input = unknown, Output = unknown> {
	readonly retrySafe?: RetrySafeOptions
	readonly onSuccess?: (output: Output, attempt: MutationAttempt<Input>) => unknown
	readonly onError?: (error: Error, attempt: MutationFailure<Input>) => unknown
}

Type parameters #

Input = unknown

Entrada de la mutación.

Output = unknown

Salida de la mutación.

Example #

ts
import type { MutationOptions } from "@meekojs/meeko/framework";

const options: MutationOptions<{ itemId: string }, { step: number }> = {
  retrySafe: { key: "kitchen:step", storage: "session" },
  onSuccess: (output, attempt) => console.log(`Paso ${output.step}`, attempt.trigger),
};
const step = useRpcMutation("kitchen.step", options);

Propiedades #

retrySafe #

propiedad sólo lectura opcional

readonly retrySafe?: RetrySafeOptions

Hace la mutación segura ante reintentos: cada intención lleva una clave de idempotencia (cabecera Idempotency-Key), se guarda antes de enviarse y, si no hay respuesta, se reintenta con la misma clave. Véase RetrySafeMutation.

onSuccess #

propiedad sólo lectura opcional

readonly onSuccess?: (output: Output, attempt: MutationAttempt<Input>) => unknown

Se llama una vez por cada intento que termina bien, también los reintentos automáticos de retrySafe, después de actualizar data, error, pending y uncertain.

onError #

propiedad sólo lectura opcional

readonly onError?: (error: Error, attempt: MutationFailure<Input>) => unknown

Se llama una vez por cada intento que falla, después de actualizar el estado.

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/app/runtime/mutations.ts