Roqueform
    Preparing search index...

    Interface FieldCore<Value, Mixin>

    Core properties of the Field.

    Note: It is recommended to use Field type whenever possible instead of FieldCore.

    interface FieldCore<Value = any, Mixin extends object = {}> {
        children: readonly Field<any, Mixin>[];
        initialValue: Value;
        isTransient: boolean;
        key: any;
        parentField: null | Field<any, Mixin>;
        value: Value;
        valueAccessor: ValueAccessor;
        at<Key extends unknown>(
            key: Key,
            defaultValue?: ValueAt<Value, Key>,
        ): Field<ValueAt<Value, Key>, Mixin>;
        flushTransient(): void;
        publish(event: FieldEvent<Mixin>): void;
        setTransientValue(value: Value | ((prevValue: Value) => Value)): void;
        setValue(value: Value | ((prevValue: Value) => Value)): void;
        subscribe(listener: (event: FieldEvent<Mixin>) => void): () => void;
    }

    Type Parameters

    • Value = any

      The field value.

    • Mixin extends object = {}

      The mixin added to the field.

    Index

    Properties

    children: readonly Field<any, Mixin>[]

    The array of child fields that were previously accessed.

    initialValue: Value

    The initial value of the field.

    isTransient: boolean

    true if the value was last updated using setTransientValue, or false otherwise.

    key: any

    The key in the parent value that corresponds to the value of this field, or null if there's no parent.

    parentField: null | Field<any, Mixin>

    The parent field, or null if this is the root field.

    value: Value

    The current value of the field.

    valueAccessor: ValueAccessor

    The accessor that reads and writes field values.

    Methods

    • Returns a child field that controls the value which is stored under the given key in the current value.

      Type Parameters

      • Key extends unknown

        The key in the value of this field.

      Parameters

      • key: Key

        The key in the value of this field.

      • OptionaldefaultValue: ValueAt<Value, Key>

        The default value used if the value at given key is undefined.

      Returns Field<ValueAt<Value, Key>, Mixin>

      The child field instance.

    • If the current value is transient then the value of the parent field is notified about the change and this field is marked as non-transient. No-op if the current value is non-transient.

      Returns void

    • Publishes an event on this field and bubbles it to the parent field.

      Parameters

      Returns void

    • Updates the value of the field, notifies child fields about the change, and marks value as transient.

      Parameters

      • value: Value | ((prevValue: Value) => Value)

        The value to set, or a callback that receives a previous value and returns a new one.

      Returns void

    • Updates the field value and notifies both ancestors and child fields about the change. If the field withholds a transient value then it becomes non-transient.

      Parameters

      • value: Value | ((prevValue: Value) => Value)

        The value to set, or a callback that receives a previous value and returns a new one.

      Returns void

    • Subscribes the listener to events published by the field.

      Parameters

      Returns () => void