TinyBase logoTinyBase

getListenerStats

The getListenerStats method provides a set of statistics about the listeners registered with the Indexes object, and is used for debugging purposes.

getListenerStats(): IndexesListenerStats
returnsIndexesListenerStats

A IndexesListenerStats object containing Indexes listener statistics.

The IndexesListenerStats object contains a breakdown of the different types of listener.

The statistics are only populated in a debug build: production builds return an empty object. The method is intended to be used during development to ensure your application is not leaking listener registrations, for example.

Example

This example gets the listener statistics of an Indexes object.

const store = createStore();
const indexes = createIndexes(store);
indexes.addSliceIdsListener(null, () => {
  console.log('Slice Ids changed');
});
indexes.addSliceRowIdsListener(null, null, () => {
  console.log('Slice Row Ids changed');
});

console.log(indexes.getListenerStats());
// -> {sliceIds: 1, sliceRowIds: 1}