off
Removes listeners created with on(). Use the same get() and next() chain that the listener was created with.
Parameter | Description |
|---|---|
| Optional. The callback to remove. Without it, every listener on the node holding the last key is removed. |
Without a callback, off() removes more than the listeners on that one key: every listener on the same node goes too, including ones on its other properties. Pass the callback to remove only that listener.
off() doesn't call the callback and doesn't return a value.
Examples
// Keep a reference to the callback.
const update = value => console.log(value)
holster.get("key").on(update)
// Later, remove just that listener.
holster.get("key").off(update)
// Remove every listener on the "item" node, including on "property".
holster.get("item").next("property").off()A listener created with the nested option is removed the same way, by passing its callback.