boxed-emitter
Scoped events.
Because events are scoped to the emitting object...except when they are not (for instance, on remote events coming through a remote stream, it's useful to have them name-spaced).
With this you can create a box on top of an event emitter (call it rooms or channels if you will) and emit scoped to that box name.
You can have multiple nested boxes.
A box supports the event emitter API plus wildcard events(opt-in).
Install
$ npm install boxed-emitter
Require
var boxedEmitter = ;
Create a boxed emitter
var emitter = ;
Wrap an existing event emitter
var EE = EventEmitter;var ee = ;var emitter = ;
You can create an event box
and give it a name:
var box = emitter;
And use that event box to emit scoped events:
// the following emits box-name::event box; // which you can listen tobox;
You can create a smaller box inside a box:
var emitter = ;var bigBox = emitter;var smallBox = bigBox; bigBox; smallBox;
You can listen to wildcard events:
// first you have to enable wildcards for this:box; box; box;
And, as a regular event emitter:
You can also remove listeners:
box;box;
And remove all listeners:
box;