Get Event History

<Array> getHistory()

Returns a list of all published elements as an array. Each element of array is an object representing element as described in elements API.

Do not call this method until LViS.setEvent callback is invoked as history might not be available until then.

There is a known issue when in some cases event does not return elements which where published while the app was not connected to the platform. The following code provides a temporary workaround by re-fetching event's history when connection is re-established. It uses undocumented method loadHistory(), so please don't use it in any other context.

let event = LViS.getEvent();
let host = LViS.getHost();

LViS.ConnectionManager.bind(LViS.ConnectionManager.ON_STATE, (state) => {
  switch (state) {
    case LViS.ConnectionManager.STATE_CONNECTED:
      event.loadHistory(host).done(() => {

Order of the results

The array will be sorted so that the most recently published elements are first, and the least recently published elements are last. In case of two elements being published at the same second, the ID will be used to provide a consistent order across runs. Notice that the ID is not auto-incremental and random in nature, so you can't guarantee the order of multiple items being published at the same time.

If you want to ensure elements are published roughly at the same time and in a specific order you can stagger them by 1 second (e.g. one element at 00:00:00, the second at 00:00:01, and so forth).


var event = LViS.getEvent();

var history = event.getHistory();