delListener
The delListener method removes a listener that was previously added to the Checkpoints object.
delListener(listenerId: string): Checkpoints| Type | Description | |
|---|---|---|
listenerId | string | The |
| returns | Checkpoints | A reference to the |
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.
import {createCheckpoints, createStore} from 'tinybase';
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.
Since
v1.0.0