destroy
The destroy
method should be called when this Checkpoints
object is no longer used.
destroy(): void
This guarantees that all of the listeners that the object registered with the underlying Store
are removed and it can be correctly garbage collected.
Example
This example creates a Store
, adds a Checkpoints
object (that registers a CellListener
with the underlying Store
), and then destroys it again, removing the listener.
import {createCheckpoints, createStore} from 'tinybase';
const store = createStore().setTables({pets: {fido: {sold: false}}});
const checkpoints = createCheckpoints(store);
console.log(store.getListenerStats().cell);
// -> 1
checkpoints.destroy();
console.log(store.getListenerStats().cell);
// -> 0
Since
v1.0.0