spoike/refluxjs — pull request #63 by krawaller (2014-09-10 06:18:56+00:00)
Title: adding the listenables prop to createStore

This adds a convenient `listenables` prop to `createStore`, which lets you easily listen to all listenables in an object (read: the return value from `createActions`).

Here's the example added to the README. If you've previously done this:

```
var actions = Reflux.createActions(["fireBall","magicMissile"]);
```

...then instead of doing this:

```javascript
var Store = Reflux.createStore({
init: function() {
this.listenTo(actions.fireBall,this.fireBall);
this.listenTo(actions.magicMissile,this.magicMissile);
},
fireBall: function(){
// whoooosh!
},
magicMissile: function(){
// bzzzzapp!
}
});
```

...you can now do this:

```javascript
var Store = Reflux.createStore({
listenables: actions,
fireBall: function(){
// whoooosh!
},
magicMissile: function(){
// bzzzzapp!
}
});
```

To enable this to be used with an object of stores too (hence the agnostic name `listenables`), I added support for `getDefaultData` in the listenable. That data is sent to the listening callback, or a `this.Default` if that exists.