can-key-tree
Version:
Add and remove items to a tree
36 lines (22 loc) • 1.02 kB
Markdown
Object} can-key-tree.types.keyTreeCallbacks KeyTreeCallbacks
can-key-tree.types
Defines callbacks `onFirst` and/or `onEmpty`.
{Object} Defines callbacks `onFirst` and/or `onEmpty`.
```js
const keyTreeCallbacks = {
onFirst: function() {
// called when the first node is added
},
onEmpty: function() {
// called when all nodes are removed
}
};
const keyTree = new KeyTree( [ Object, Object, Array ], keyTreeCallbacks );
function handler1() {}
keyTree.add( [ "click", "li", handler1 ] );
// onFirst is called with a context (`this`) of the keyTree instance and no arguments
keyTree.delete( [] );
// onEmpty is called with a context (`this`) of the keyTree instance and no arguments
```
{Function} [onFirst] called with a context (`this`) of the keyTree instance and no arguments when the tree gets its first item added.
{Function} [onEmpty] called with a context (`this`) of the keyTree instance and no arguments when the tree becomes empty.
{