delListener
The delListener
method removes a listener that was previously added to the Indexes
object.
delListener(listenerId: Id): Indexes
Type | Description | |
---|---|---|
listenerId | Id | 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.
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',
(indexes, indexId) => {
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.