Class Store<RecordType>

Generic data store used by components

Type Parameters

Hierarchy

Constructors

Properties

_loaded: boolean = false
_loading: boolean = false
items: RecordType[]
sort: Comparator[] = []

Sort the data on field and direction

Accessors

  • get data(): RecordType[]
  • Returns RecordType[]

  • set data(records): void
  • Parameters

    • records: RecordType[]

    Returns void

  • get loaded(): boolean
  • True when data has been loaded at least once

    Returns boolean

  • get loading(): boolean
  • True when the store is loading

    Returns boolean

Methods

  • Add items at the end

    Parameters

    • Rest ...items: RecordType[]

    Returns number

    the index of the last added item

  • The filter() method creates a new array with all elements that pass the test implemented by the provided function.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

        • (value, index, obj): unknown
        • Parameters

          • value: RecordType
          • index: number
          • obj: RecordType[]

          Returns unknown

    Returns RecordType[]

    CollectionItem | undefined

  • Returns the value of the first element in the array where predicate is true, and undefined otherwise.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

        • (value, index, obj): unknown
        • Parameters

          • value: RecordType
          • index: number
          • obj: RecordType[]

          Returns unknown

    Returns undefined | RecordType

    CollectionItem | undefined

  • Returns the index of the first element in the array where predicate is true, and -1 otherwise.

    Parameters

    • predicate: ((value, index, obj) => unknown)

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.

        • (value, index, obj): unknown
        • Parameters

          • value: RecordType
          • index: number
          • obj: RecordType[]

          Returns unknown

    Returns number

  • Fire an event

    When a listener returns false this function will return false too.

    Type Parameters

    Parameters

    • eventName: K
    • Rest ...args: Parameters<StoreEventMap<any, RecordType>[K]>

    Returns boolean

  • Performs the specified action for each element in an array.

    Parameters

    • callbackfn: ((value, index, array) => void)

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

        • (value, index, array): void
        • Parameters

          • value: RecordType
          • index: number
          • array: RecordType[]

          Returns void

    • Optional thisArg: any

      An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

    Returns void

  • Get an item at the given index

    Parameters

    • index: number

    Returns undefined | RecordType

  • Insert items at the given index

    Parameters

    • index: number

      Use negative indexes to insert from the end. For example -1 inserts before the last item.

    • Rest ...items: RecordType[]

    Returns number

  • Protected

    Returns the loaded records. If append is true it only returns the new records. Override this function for new store types.

    Parameters

    • append: boolean

    Returns Promise<RecordType[]>

  • Loads the data from source into the store

    Parameters

    • append: boolean = false

    Returns Promise<RecordType[]>

  • Load a set of records

    Parameters

    • records: RecordType[]
    • append: boolean = true

    Returns void

  • Load the next set of records when paging. Doesn't do anything in the array store but can be implemented in async stores.

    Parameters

    • append: boolean = false

    Returns Promise<RecordType[]>

  • Load the next set of records when paging. Doesn't do anything in the array store but can be implemented in async stores.

    Returns Promise<RecordType[]>

  • Reload the data from the source

    Returns Promise<RecordType[]>

Generated using TypeDoc