Interface Binding<GetType>

A binding is a stored piece of data that notifies registered listeners when changed.

See

useBinding

interface Binding<GetType> {
    addChangeListener: ((listener) => ChangeListenerRemover);
    get: (() => GetType);
    getChangeUid: (() => string);
    id: string;
    isBinding: true;
    isLocked: (() => boolean);
    isModified: (() => boolean);
    lock: (() => (() => void));
    reset: (() => void);
    set: ((newValue) => void);
    setIsModified: ((isModified) => void);
    setRaw: ((newValue) => void);
    setValueTransformer?: SetValueTransformer<GetType>;
    triggerChangeListeners: (() => void);
    uid: string;
}

Type Parameters

  • GetType = any

Hierarchy (view full)

Properties

addChangeListener: ((listener) => ChangeListenerRemover)

Adds a listener that will be called when this binding changes.

Type declaration

See

useBindingEffect and BindingsConsumer

Returns

a function that may be used to remove the added listener.

get: (() => GetType)

Type declaration

Returns

the value

getChangeUid: (() => string)

Every time the value is changed, the change uid is updated

Type declaration

    • (): string
    • Every time the value is changed, the change uid is updated

      Returns string

id: string

A technical, but human-readable ID, which isn't guaranteed to be unique

isBinding: true

A marker indicating that this is a binding type

isLocked: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

      true if the binding is locked

Returns

true if the binding is locked

isModified: (() => boolean)

Type declaration

    • (): boolean
    • Returns boolean

      true if this binding has been marked as being modified

Returns

true if this binding has been marked as being modified

lock: (() => (() => void))

Increments the lock count and returns a method to decrement it. A binding is locked if its lock count is > 0. When a binding is locked, mutating calls (reset/set/setRaw) won't have an immediate effect. However, if a mutating call is made on a locked binding, the change will be applied once the binding becomes unlocked.

Type declaration

    • (): (() => void)
    • Increments the lock count and returns a method to decrement it. A binding is locked if its lock count is > 0. When a binding is locked, mutating calls (reset/set/setRaw) won't have an immediate effect. However, if a mutating call is made on a locked binding, the change will be applied once the binding becomes unlocked.

      Returns (() => void)

      a function for decrementing this binding's lock count.

        • (): void
        • Returns void

Returns

a function for decrementing this binding's lock count.

reset: (() => void)

Resets the binding back to its initial value and marks the binding as non-modified.

Type declaration

    • (): void
    • Resets the binding back to its initial value and marks the binding as non-modified.

      Returns void

set: ((newValue) => void)

Sets the value, using the result of setValueTransformer if set, and then marks the binding as modified.

Type declaration

    • (newValue): void
    • Sets the value, using the result of setValueTransformer if set, and then marks the binding as modified.

      Parameters

      Returns void

setIsModified: ((isModified) => void)

Sets the binding as having been modified or not

Type declaration

    • (isModified): void
    • Sets the binding as having been modified or not

      Parameters

      • isModified: boolean

      Returns void

setRaw: ((newValue) => void)

Sets the internal value without transforming or marking as changed. Don't normally use this!

Type declaration

    • (newValue): void
    • Sets the internal value without transforming or marking as changed. Don't normally use this!

      Parameters

      Returns void

setValueTransformer?: SetValueTransformer<GetType>

If set, a function to transform the value before it's stored

triggerChangeListeners: (() => void)

Forcibly triggers the change listeners. Don't normally use this!

Type declaration

    • (): void
    • Forcibly triggers the change listeners. Don't normally use this!

      Returns void

uid: string

An ID that's unique to this runtime

Generated using TypeDoc