A new contender is in town, the super simple Flux-like library called Reflux, and in terms of features is now more in parity with the original Flux than ever possibly before.

I also renamed the github project to refluxjs, so it'll be easier to track on Twitter and find on Google.

Other than fixing bugs the current version, v0.1.6, now has a full-on replacement for the waitFor function, and it's even better!

Previously we solved the need to create sequential data flows:

Action.add <-- listens to -- TodoStore <-- listens to -- PersistanceStore

By letting you chain stores together, creating a store that is aggregate to another:

var persistanceStore = Reflux.createStore({  
    init: function() {
        this.listenTo(todoStore);
    },
    callback: function(newData) { /* ... */ }
});

You can now create parallel data flows and join them together:

 WaveAction <--+
               joins -- TheTide <-- listens to -- ClockStore
 TimeStore <---+

Joining is done with ease by using Reflux.all. Wonder how? More down below.

Joining actions and stores together

Thanks to the effort of @bripkens we now have a better way to handle parallel flows, by joining them with Reflux.all.

// Join together emits from an action and a data store
var theTide = Reflux.all(waveAction, timeStore);

// Now your aggregate store may receive them once they're both
// emitted through one callback
var clockStore = Reflux.createStore({  
    init: function() {
        this.listenTo(theTide, this.theTideCallback);
    },
    theTideCallback: function(waveActionArgs, timeStoreArgs) {
      // Arguments from waveAction is passed as 
      // an array in "waveActionArgs" and arguments from
      // timeStore is passed as an array in "timeStoreArgs"

      // Insert code to handle them here...
    }
});

The biggest benefit is that you can reuse this join. How about a poor man's trace?

// simple argument trace whenever waveAction and timeStore emits

theTide.listen(function() {  
    console.log(arguments);
});

Now isn't that nice?

Detecting Those Nasty Loops

In larger web applications, it'll be difficult to keep track of how the actions and stores are linked to each other, and you'll end up at risk of creating an infinite event loop.

In order to make it clear that you suddenly decided to listen to a store that causes a loop de loop that will cause your app to overflow the poor stack, Reflux will tell you as early as when your web application is setting it up.

waveAction.listensTo(theTide);  
// Will now throw an error instead of waiting for you 
// to exerce the emitters that will cause the problematic
// infinite loop

What's in Store For Us

More features are planned as we fake it 'til we break it. Want a feature that you're dying for, did you find a nasty bug that needs to be fixed, or do you want some help using Reflux? Please visit our issue tracker and communicate!

See ya!