FormController interface

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

interface FormController

One state over a View's fields (createFieldController): whether the form is dirty, settled and valid, and a submit that writes every field before its command, so Save never runs before the last keystroke reached .NET.

Properties

current

readonly current: FormState;

The form's state now. Read it again after the View's state changed: fields learn of it without notifying.

Methods

subscribe

subscribe(listener: () => void): () => void;

Calls listener after a field's state changed or a submit started or ended, until the returned function is called.

commit

commit(): Promise<FormState>;

Commits every field (a commit: "pause" draft is written now) and resolves once their writes settled.

submit

submit<T>(command: () => T | PromiseLike<T>, options?: FormSubmitOptions): Promise<FormSubmitResult<T>>;

Commits every field, waits for their writes and runs command unless a field's write or text failed: await form.submit(() => editor.save()). While it runs submitting is true and another submit is busy.

reset

reset(): void;

Resets every field: drops drafts, errors and conflicts and shows the View's values.

dispose

dispose(): void;

Stops notifying. The fields stay; their owner disposes them.