Class DataSourceStore<DataSource, StoreRecord>

DataSourceStore class

Uses an {@see AbstractDataSource} to present data in the view.

Type Parameters

Hierarchy

  • Store<StoreRecord>
    • DataSourceStore

Constructors

Properties

buildRecord: RecordBuilder<dataSourceEntityType<DataSource>, StoreRecord> = ...

Builds record from entity

Param

dataSource: DataSource
filters: Record<string, any> = {}
hasMore: boolean = false
items: StoreRecord[]
monitorChanges: boolean = true

Reload when the datasource changes

queryParams: Omit<QueryParams, "sort"> = {}
relations?: Partial<Record<keyof DefaultEntity, {
    dataSource: AbstractDataSource<DefaultEntity>;
    path: string;
}>>
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: StoreRecord[]

    Returns number

    the index of the last added item

  • Load more data when this element is scrolled down

    Parameters

    • el: HTMLElement

    Returns (() => void)

      • (): void
      • Returns void

  • 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: StoreRecord
          • index: number
          • obj: StoreRecord[]

          Returns unknown

    Returns StoreRecord[]

    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: StoreRecord
          • index: number
          • obj: StoreRecord[]

          Returns unknown

    Returns undefined | StoreRecord

    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: StoreRecord
          • index: number
          • obj: StoreRecord[]

          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, StoreRecord>[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: StoreRecord
          • index: number
          • array: StoreRecord[]

          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 | StoreRecord

  • Check if the given item is present

    Parameters

    • item: StoreRecord

    Returns boolean

  • Find the index of an item. Returns -1 if not found.

    Parameters

    • item: StoreRecord

    Returns number

  • 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: StoreRecord[]

    Returns number

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

    Parameters

    • append: boolean = false

    Returns Promise<Awaited<StoreRecord>[]>

  • Loads the data from source into the store

    Parameters

    • append: boolean = false

    Returns Promise<StoreRecord[]>

  • Load a set of records

    Parameters

    • records: StoreRecord[]
    • 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<StoreRecord[]>

  • 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<StoreRecord[]>

  • Protected

    Reloads the store when the datasource changes

    Parameters

    • DataSource: DataSource
    • changes: Changes

    Returns Promise<void>

  • Replace the collection with an array

    Parameters

    • Rest ...items: StoreRecord[]

    Returns void

Generated using TypeDoc