delListener
The delListener method removes a listener that was previously added to the Indexes object.
delListener(listenerId: string): Indexes| Type | Description | |
|---|---|---|
listenerId | string | The |
| returns | Indexes | A reference to the |
Use the Id returned by whichever method was used to add the listener. Note that the Indexes object may re-use this Id for future listeners added to it.
Example
This example creates a Store, an Indexes object, registers a listener, and then removes it.
import {createIndexes, createStore} from 'tinybase';
const store = createStore().setTable('pets', {
fido: {species: 'dog'},
felix: {species: 'cat'},
cujo: {species: 'dog'},
});
const indexes = createIndexes(store);
indexes.setIndexDefinition('bySpecies', 'pets', 'species');
const listenerId = indexes.addSliceIdsListener('bySpecies', () => {
console.log('Slice Ids for bySpecies index changed');
});
store.setRow('pets', 'lowly', {species: 'worm'});
// -> 'Slice Ids for bySpecies index changed'
indexes.delListener(listenerId);
store.setRow('pets', 'toto', {species: 'dog'});
// -> undefined
// The listener is not called.
Since
v1.0.0