delListener
The delListener
method removes a listener that was previously added to the Store
.
delListener(listenerId: string): this
Type | Description | |
---|---|---|
listenerId | string | The |
returns | this | A reference to the |
Use the Id
returned by whichever method was used to add the listener. Note that the Store
may re-use this Id
for future listeners added to it.
Example
This example registers a listener and then removes it.
import {createStore} from 'tinybase';
const store = createStore().setTables({
pets: {fido: {species: 'dog', color: 'brown'}},
});
const listenerId = store.addTablesListener(() => {
console.log('Tables changed');
});
store.setCell('pets', 'fido', 'color', 'walnut');
// -> 'Tables changed'
store.delListener(listenerId);
store.setCell('pets', 'fido', 'color', 'honey');
// -> undefined
// The listener is not called.
Since
v1.0.0