TinyBase logoTinyBase

getListenerStats

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

getListenerStats(): CheckpointsListenerStats
returnsCheckpointsListenerStats

A CheckpointsListenerStats object containing Checkpoints listener statistics.

The CheckpointsListenerStats 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 a Checkpoints object.

const store = createStore();
const checkpoints = createCheckpoints(store);
checkpoints.addCheckpointIdsListener(() => {
  console.log('Checkpoint Ids changed');
});
checkpoints.addCheckpointListener(null, () => {
  console.log('Checkpoint label changed');
});

console.log(checkpoints.getListenerStats());
// -> {checkpointIds: 1, checkpoint: 1}