Class DataStore<T>

Type Parameters

Hierarchy

Constructors

Properties

m_fields: FieldInfo[]
m_model: T
m_proxy: DataProxy
m_rec_index: Uint32Array
m_records: T[]

Accessors

Methods

  • emit an event you can stop propagation of event or prevent default

    Type Parameters

    • K extends "data_change"

    Parameters

    • type: K
    • Optional event: DataStoreEventMap[K]

      event data

    Returns void

  • Parameters

    • cb: ((rec, index) => any)
        • (rec, index): any
        • Parameters

          • rec: T
          • index: number

          Returns any

    Returns void

  • return the record by it's id

    Parameters

    • id: any

    Returns T

    record or null

  • return a record by it's index

    Parameters

    • index: number

    Returns T

    record or null

  • find the index of the element with the given id

    Parameters

    • id: any

    Returns number

  • Parameters

    • Optional url: string

    Returns Promise<void>

  • stop listening to an event

    Type Parameters

    • K extends "data_change"

    Parameters

    • type: K
    • callback: ((ev) => any)

      callback to remove (must be the same as in on )

        • (ev): any
        • Parameters

          • ev: DataStoreEventMap[K]

          Returns any

    Returns void

  • listen for an event

    Type Parameters

    • K extends "data_change"

    Parameters

    • type: K
    • callback: ((ev) => any)

      callback to call

        • (ev): any
        • Parameters

          • ev: DataStoreEventMap[K]

          Returns any

    Returns EventDisposer

  • handle an event one time

    Type Parameters

    • K extends "data_change"

    Parameters

    • type: K
    • callback: ((ev) => any)

      callback to call when event is signaled

        • (ev): any
        • Parameters

          • ev: DataStoreEventMap[K]

          Returns any

    Returns void

    Promise if callback is null

    take care with that because if the event is never fired and you await it, the system may overflow

  • convert raw objects to real records from model

    Parameters

    • records: any[]

    Returns void

  • just set the records

    Parameters

    • records: T[]

      must be of the same type as model

    Returns void

  • signal en event signaled event are notification : no way to prevent default not stop propagation

    Type Parameters

    • K extends "data_change"

    Parameters

    • type: K
    • event: DataStoreEventMap[K]

      event data

    • delay: number = -1

    Returns void

Generated using TypeDoc