FieldHandle interface

Module @runic-artifex/angular in @runic-artifex/angular 0.23.0

interface FieldHandle<TValue>

One View member bound to an input, as signals. See FieldState and FieldController in @runic-artifex/views.

Properties

value

readonly value: Signal<TValue>;

The draft while one exists, otherwise the member's value in the View's state.

text

readonly text: Signal<string>;

What a text input shows: the text typed while it does not parse or still means value, otherwise value formatted.

editing

readonly editing: Signal<boolean>;

True while a draft exists, from the first input until the last write settled and the state caught up, and after a failed write. Keep the input enabled while it is true, rather than disabling it on the View's busy state, which the field's own write causes.

error

readonly error: Signal<unknown>;

Why the latest write or text failed: a BridgeError of the write, or a FieldError. undefined otherwise.

errors

readonly errors: Signal<readonly string[]>;

The member's validation messages; [] when valid.

conflict

readonly conflict: Signal<FieldBaseline<TValue> | undefined>;

The producer's value and version while a checked write's conflict keeps the draft.

validating

readonly validating: Signal<boolean>;

The member's validation is in progress, such as an asynchronous rule that is still checking: show "checking…".

field

readonly field: FieldController<unknown, unknown, TValue>["field"];

The definition's kind, nullable, integer and choices.

Methods

input

input(value: TValue): void;

The user changed the value, such as a checkbox's checked.

inputText

inputText(event: Event | string): void;

The user changed the text: pass the input event, or the text. It is parsed for the field's kind.

compositionStart

compositionStart(): void;

An IME composition started: the text is kept but not written until it ends. Bind it to compositionstart.

compositionEnd

compositionEnd(event: Event | string): void;

The IME composition ended: pass the compositionend event, or the text, which is then written.

commit

commit(): Promise<FieldState<TValue>>;

The user is done with the field (bind it to blur): with commit: "pause" the draft is written now. Resolves with the field's state once its writes settled, so a command that depends on the field can follow it.

retry

retry(): void;

Writes the draft again after a failed write; after a conflict, over the producer's value.

reset

reset(): void;

Drops the draft, the error and a conflict and shows the View's value. Writes in flight still complete.