spoike/refluxjs — pull request #92 by krawaller (2014-10-02 05:46:12+00:00)
Title: adding join methods

The refactor of `Reflux.all` in #84 paved the way to implement the various join strategies as discussed by @bripkens and @spoike in #28 and #29. This pull request adds the following methods to the `ListenerMethods`:

* `listener.joinLeading`
* `listener.joinTrailing`
* `listener.joinConcat`
* `listener.joinStrict`

...which corresponds to the four strategies outlined in previous discussions. Here's the new readme example:

```javascript
var gainHeroBadgeStore = Reflux.createStore({
init: function() {
this.joinTrailing(actions.disarmBomb, actions.saveHostage, actions.recoverData, this.triggerAsync);
}
});

actions.disarmBomb("warehouse");
actions.recoverData("seedyletter");
actions.disarmBomb("docks");
actions.saveHostage("offices",3);
// `gainHeroBadgeStore` will now asyncronously trigger `[["docks"],["offices",3],["seedyletter"]]`.
```

I also expose them as static methods on the `Reflux` object, which automatically sets up the store and creates the join with triggerAsync as callback. As shown in the readme, the store in the example could then be created like this:

```javascript
var gainHeroBadgeStore = Reflux.joinTrailing(actions.disarmBomb, actions.saveHostage, actions.recoverData);
```

The old `Reflux.all` method now corresponds to `Reflux.joinTrailing`. I've kept `all` as an alias for backwards compatibility.

I created a new test file for the join functionality, but kept the old one (`composedListenable.spec.js`) around as it also tests some composite stuff.