TinyBase logoTinyBase

delListener

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

delListener(listenerId: Id): Store
TypeDescription
listenerIdId

The Id of the listener to remove.

returnsStore

A reference to the Store.

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.

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.