emit events to every listener in object tree
$ component install stagas/tree-emit
var emit = require('tree-emit');
function print(s) {
document.write(s);
}
var obj = {
onfoo: print,
some: {
notonfoo: print,
level: {
other: 'ignored',
deep: {
onfoo: print
}
}
}
};
emit(obj, 'foo', 'bar'); // => barbar
Emit name
event to target
passing following parameters.
Emit depth-first as method.
Emit breadth-first.
Filter traversal using fn
.
The passed function is invoked with
(key, property)
and must return
true
or false
depending on whether
to traverse down that property.
Intercept an emitter
and
tree-emit its events to out
.
Wrap emitter
to tree-emit on itself.
MIT