submission.svelte.ts overview

The submit lifecycle every bundled form shares, as a rune-backed factory: a .svelte.ts module so $state works, and one form may own several.


Exports Grouped by Category


utils

Submission (interface)

One form’s submit lifecycle. @internal

Signature

export interface Submission {
  /** `true` while a request is in flight. */
  readonly pending: boolean
  /** The failure to render, or `None`. */
  readonly failure: Option.Option<FormFailure>
  /** `true` once a submit has resolved and nothing has been re-submitted. */
  readonly succeeded: boolean
  /** Record a client-side validation failure against `field`. */
  readonly fail: (message: string, field: string) => void
  /**
   * Run `work`, tracking pending/error state and firing the callbacks;
   * `fallback` is the message shown when the thrown value carries none.
   */
  readonly run: <T>(
    work: () => Promise<T>,
    fallback: string,
    onSuccess?: (result: T) => void,
    onError?: (error: unknown) => void
  ) => Promise<void>
}

Source

createSubmission

Own the submit/pending/error state of one form (or one step of one). @internal

Signature

declare const createSubmission: () => Submission

Source


This site uses Just the Docs, a documentation theme for Jekyll.