LiveCollection

LiveCollection

The LiveCollection API allows easily retrieve the queried data asynchronously, as well as subscribe to any new changes to the data.
Note: you will never need to create a LiveCollection instances directly. They are returned by SDK's repositories APIs

LiveCollection instance fires:
- dataStatusChanged
- loadingStatusChanged
- dataUpdated
- dataError

Extends

  • EventEmitter

Members

(readonly) dataStatus :EkoDataStatus

The LiveCollection data status.
Type:

(readonly) loadingStatus :EkoLoadingStatus

The LiveCollection loading status.
Type:

(readonly) models :Array.<Object>

Get an array of the LiveCollection records.
Type:
  • Array.<Object>

(readonly) hasMore :boolean

Defines if any more records are available.
Type:
  • boolean
Example
const collection = new someRepositoryInstance.allRecords();
console.log(collection.hasMore); // false => it is always false until the collection finishes first request
collection.once('loadingStatusChanged', () => {
    if (collection.loadingStatus === EkoLoadingStatus.Loaded) {
        console.log(collection.hasMore); // true or false
    }
});

Methods

resetPage()

Reset the current records being contained to the default first page.

nextPage()

Requests more records to load if any are available.

dispose()

Disposes the LiveCollection instance. Stops all observers, removes all listeners and cleans internal data.

Events

dataError

Fires every time when asynchronous error occurs.
Type:
  • EkoSDKError

dataStatusChanged

Properties:
Name Type Attributes Description
oldValue EkoDataStatus <optional>
The old data status.
newValue EkoDataStatus The new data status.
Fires every time when dataStatus changes.
Type:
  • Object

loadingStatusChanged

Properties:
Name Type Attributes Description
oldValue EkoLoadingStatus <optional>
The old loading status.
newValue EkoLoadingStatus The new loading status.
Fires every time when loadingStatus changes.
Type:
  • Object

dataUpdated

Fires every time when data models updated.
Type:
  • Array.<Object>