turbodombuilder - v0.9.48
    Preparing search index...

    Class TurboYBlock<YType, KeyType, IdType>

    Type Parameters

    • YType extends YMap | YArray = YMap | YArray
    • KeyType extends string | number | symbol = any
    • IdType extends string | number | symbol = any

    Hierarchy (View Summary)

    Index

    Constructors

    • Type Parameters

      • YType extends YMap<any> | YArray<any> = YMap<any> | YArray<any>
      • KeyType extends string | number | symbol = any
      • IdType extends string | number | symbol = any

      Parameters

      Returns TurboYBlock<YType, KeyType, IdType>

      Create a new TurboDataBlock.

    Properties

    id: IdType
    isInitialized: boolean = false
    changeObservers: TurboWeakSet<TurboObserver<any, any, KeyType, string>> = ...
    onKeyChanged: Delegate<(key: KeyType, value: any) => void> = ...

    Delegate fired when the value changes at a certain key/index.

    observerConstructor: new (...args: any[]) => TurboObserver = ...

    The default class of observers to instantiate.

    Type Declaration

    Accessors

    • get data(): DataType

      Returns DataType

      The data held by this block. Setting it will clear attached observers and re-initialize the block.

    • set data(data: DataType): void

      Parameters

      Returns void

    • get values(): any[]

      Returns any[]

      The block's values in an array (in the order implied by keys).

    • set enabledCallbacks(value: boolean): void

      Parameters

      • value: boolean

      Returns void

      Whether callbacks are enabled.

    • get keys(): KeyType[]
      Function

      keys

      Returns KeyType[]

      Array of keys.

      Retrieves all keys within the given block(s).

    • get size(): number
      Function

      size

      Returns number

      The size.

      Returns the size of the specified block.

    Methods

    • Function

      toJSON

      Returns object

      • Plain JSON-serializable representation.

      Convert the block into a plain object suitable for JSON serialization.

    • Function

      unlink

      Returns void

      Detach any previously-linked host.

    • Function

      makeSignal

      Type Parameters

      • Type = any

        The type of the signal's value.

      Parameters

      • key: KeyType

        The key for which to create the signal.

      Returns SignalBox<Type>

      • The created or cached signal.

      Create (or return an existing) reactive SignalBox for the given key. The returned signal reads from get and writes via set.

    • Function

      getSignal

      Parameters

      • key: KeyType

        The key whose signal to retrieve.

      Returns any

      • The signal or undefined if none was created.

      Retrieve an existing SignalBox for the given key if present.

    • Function

      makeAllSignals

      Returns void

      Create signals for every key currently present in the block.

    • Protected Function

      keyChanged

      Parameters

      • key: KeyType

        The key that changed.

      • Optionalvalue: unknown = ...

        The new value (or undefined for deletions).

      • Optionaldeleted: boolean = false

        Whether the key was removed.

      Returns void

      Internal hook called whenever a key is added/updated/deleted.

    • Function

      get

      Parameters

      Returns unknown

      The value associated with the key, or null if not found.

      Retrieves the value associated with a given key in the specified block.

    • Function

      set

      Parameters

      • key: KeyType

        The key to update.

      • value: unknown

        The value to assign.

      Returns void

      Sets the value for a given key in the specified block and triggers callbacks (if enabled).

    • Function

      add

      Parameters

      • value: unknown

        The value to insert.

      • Optionalkey: KeyType

        Optional numeric index to insert at. If omitted, the value is pushed.

      Returns void | KeyType

      • The index where the value was inserted (for arrays), or void for non-arrays.

      Append or insert a value into an array-backed data block. If the block is not an array, the call forwards to set.

    • Function

      has

      Parameters

      • key: KeyType

        The key/index to check.

      Returns boolean

      • True, if present.

      Check whether the given key exists in the block.

    • Function

      delete

      Parameters

      • key: KeyType

        The key/index to remove.

      Returns void

      Remove the entry at the given key/index and notify observers.

    • Function

      initialize

      Returns void

      Initializes the block at the given key, and triggers callbacks for all the keys in its data.

    • Function

      clear

      Parameters

      • clearData: boolean = true

        If true, also clears the stored data. Otherwise, only resets observers/state.

      Returns void

      Clear the block and its observers.

    • Parameters

      • event: YEvent
      • transaction: any

      Returns void