[]previous and next page

Submission

One submission, with its state as accessors.

One submission, with its state as accessors. The store keeps it until it is cleared or dropped.

Import#

ts
import type { Submission } from "@shadow-js/dusk/client";

Signature#

ts
interface Submission<Input = unknown, Output = unknown> {
  /** Stable within a page: `s1`, `s2`, ... in the order the submissions started. */
  readonly id: string;
  /** The key of the submission: a server function id, or any string. */
  readonly key: string;
  /** What was submitted: the arguments, or the `FormData` of a form. */
  readonly input: Input;
  /** `pending`, `success` or `error` (`idle` once cleared). */
  readonly status: Accessor<SubmissionStatus>;
  /** True while the call runs. */
  readonly pending: Accessor<boolean>;
  /** The value of the call; a `fail()` result is here too (see `failed`). */
  readonly result: Accessor<Output | undefined>;
  /** True when the result is a `fail()` failure. */
  readonly failed: Accessor<boolean>;
  /** The thrown error of an `error` submission, or the error of a revalidation that failed after a success. */
  readonly error: Accessor<unknown>;
  /** Settles when the call (and its revalidation) has finished, whatever the outcome. */
  readonly done: Promise<void>;
  /** Removes the submission from the store and resets its state to `idle`. */
  clear(): void;
  /** Runs the call again with the same input. */
  retry(): Promise<void>;
}

Members#

Name Type Description
Input Input = unknown
Output Output = unknown
id readonly id: string Stable within a page: s1, s2, ... in the order the submissions started.
key readonly key: string The key of the submission: a server function id, or any string.
input readonly input: Input What was submitted: the arguments, or the FormData of a form.
status readonly status: Accessor<SubmissionStatus> pending, success or error (idle once cleared).
pending readonly pending: Accessor<boolean> True while the call runs.
result readonly result: Accessor<Output | undefined> The value of the call; a fail() result is here too (see failed).
failed readonly failed: Accessor<boolean> True when the result is a fail() failure.
error readonly error: Accessor<unknown> The thrown error of an error submission, or the error of a revalidation that failed after a success.
done readonly done: Promise<void> Settles when the call (and its revalidation) has finished, whatever the outcome.
clear clear(): void Removes the submission from the store and resets its state to idle.
retry retry(): Promise<void> Runs the call again with the same input.