hoodiehq/hoodie.js — pull request #131 by gr2m (2013-09-02 18:15:06+00:00)
Title: V0.4 peanuts flexible events module

with the new implementation, we can dry out the core extensions. e.g. in store.js, instead of

```js
// trigger
// ---------

// proxies to hoodie.trigger
api.trigger = function trigger() {
var eventName = arguments[0];
var parameters = 2 <= arguments.length ? Array.prototype.slice.call(arguments, 1) : [];
var prefix = storeName;

return hoodie.trigger.apply(hoodie, [prefix + ':' + eventName].concat(Array.prototype.slice.call(parameters)));
};

// on
// ---------

// proxies to hoodie.on
api.on = function on(eventName, data) {
var prefix = storeName;

eventName = eventName.replace(/(^| )([^ ]+)/g, '$1'+prefix+':$2');

return hoodie.on(eventName, data);
};

// unbind
// ---------

// proxies to hoodie.unbind
api.unbind = function unbind(eventName, callback) {
var prefix = storeName;

eventName = eventName.replace(/(^| )([^ ]+)/g, '$1'+prefix+':$2');
return hoodie.unbind(eventName, callback);
};
```

we now can do

```js
hoodieEvents(hoodie, { context: api, namespace: storeName })
```