TinyBase logoTinyBase

delListener

The delListener method removes a listener that was previously added to the Checkpoints object.

delListener(listenerId: Id): Checkpoints
TypeDescription
listenerIdId

The Id of the listener to remove.

returnsCheckpoints

A reference to the Checkpoints object.

Use the Id returned by the addCheckpointIdsListener method. Note that the Checkpoints object may re-use this Id for future listeners added to it.

Example

This example creates a Store, a Checkpoints object, registers a listener, and then removes it.

const store = createStore().setTables({pets: {fido: {sold: false}}});

const checkpoints = createCheckpoints(store);
console.log(checkpoints.getCheckpointIds());
// -> [[], '0', []]

const listenerId = checkpoints.addCheckpointIdsListener(() => {
  console.log('checkpoints changed');
});

store.setCell('pets', 'fido', 'species', 'dog');
// -> 'checkpoints changed'

checkpoints.addCheckpoint();
// -> 'checkpoints changed'

checkpoints.delListener(listenerId);

store.setCell('pets', 'fido', 'sold', 'true');
// -> undefined
// The listener is not called.