createFieldController function

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

function createFieldController<TState, TClient, TValue>(definition: FieldDefinition<TClient, TState, TValue>, options?: FieldOptions<TValue>): FieldController<TState, TClient, TValue> & Disposable;

Creates a FieldController for a generated BridgeField, such as EditorFields.title, or any definition with read and write. A using declaration disposes it where the engine has Symbol.dispose.

const title = createFieldController(EditorFields.title, { commit: "pause" });
editor.subscribe(state => title.setSource({ state, client: editor }));
input.addEventListener("input", () => title.inputText(input.value));
input.addEventListener("blur", () => title.commit());