kamicane/emi — Issue #1: tweaks
Author: jdalton
Created: 2012-03-03 00:02:32+00:00
State: open

1. You could drop the [check for duplicate event listeners](https://github.com/kamicane/emi/blob/e84fb40697266dcea6327e74f57b62c2ba08b55b/lib/main.js#L26) in `on`.
It's pretty edge and if a dev is attempting it they probably want to.
jQuery allows duplicates because it helps keep their event system open/flexible enough for things like namespaced events. By keeping the event system dumb you give the dev more control.

2. Shallow clone your listeners before emitting them so listeners that call `on` or `off` won't muck up the current iterating listeners.

3. Allow `on` to accept a space separated string of event types `foo.on('click touch', listener)` and allow `off` to be called like`foo.off('click')` to remove all "click" listeners or `foo.off()` to remove all listeners.

4. Instead of [slicing arguments](https://github.com/kamicane/emi/blob/e84fb40697266dcea6327e74f57b62c2ba08b55b/lib/main.js#L42) in your `emit` method you could standardize on always passing an event object *(asumes the presence of a simple Event constructor)*:

~~~ js
// instead of this...
var args = Array.prototype.slice.call(arguments, 1);

// you could have this...
arguments[0] = new Event(event);
~~~