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.

FormSubmission

tipo Since 1.5.0 No import

Cómo terminó un envío de Form.trySubmit:

  • { ok: true, result }: submit terminó bien y devolvió result.
  • { ok: false, reason: "invalid" }: los datos no superaron el schema del navegador, o el servidor respondió con issues (un 400, o un ApiError con issues); errors y error son los mensajes que muestra el formulario, y failure, el ClientError del servidor (null si validó el navegador).
  • { ok: false, reason: "error" }: el envío falló sin issues, como un 409 o un fallo de red; error es el texto de errorMessage (null si un reset lo descartó).
  • { ok: false, reason: "skipped" }: no se envió nada, porque ya había un envío en curso, porque el script se ejecuta sólo para producir HTML (SSR) o porque un reset descartó los valores mientras el schema validaba.

Se autoimporta en los componentes y en app/.

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

Source code src/app/composables/useForm.ts:162

Declaración #

ts
type FormSubmission<Result> =
| {
		readonly ok: true
		readonly result: Result
  }
| {
		readonly ok: false
		readonly reason: 'invalid'
		readonly errors: Readonly<Record<string, string>>
		readonly error: string | null
		readonly failure: Error | null
  }
| {
		readonly ok: false
		readonly reason: 'error'
		readonly error: string | null
		readonly failure: Error
  }
| {
		readonly ok: false
		readonly reason: 'skipped'
  }

Type parameters #

Result

Lo que devuelve submit cuando el envío termina bien.

Example #

ts
async function save(event: SubmitEvent): Promise<void> {
  const outcome = await form.trySubmit(event);
  if (outcome.ok) lastSaved.value = outcome.result.updatedAt;
  else if (outcome.reason === "error") console.warn(outcome.failure);
}

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/composables/useForm.ts