-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Joining parallel listeners to one #27
Comments
Alternative (no. 2) is to keep the var dataStore = Reflux.createStore({
init: function() {
this.listenTo(anAction,
anotherAction,
anotherStore /* , ... */,
this.callback);
},
callback: function(anActionArgs,
anotherActionArgs,
anotherStoreArgs /*, ... */) {
// ...
}
}); |
Your second alternative seems more intuitive to me. We could even get a bit closer to the ES 6 Promise interface by using something like this (referring to
This has the added benefit that event synchronization is the sole responsibility of |
I'd be glad to provide an initial implementation for this. |
I really like the |
Isn't this a |
Yeah, it essentially is @dashed. We could argue if it should be in scope of the project or not, but after reading this blog post on react blog, I caved in for the need to handle data coming in parallel. It is however a different need from chaining stores (which Facebook React suggests you do with As @bripkens says, responsibility for the synchronization stays within Reflux.all. The only thing stores care about is that they listen to something, i.e. adher to an interface with a listen function. It has the added benefit of a simple monkey patching possibility, e.g. if anyone wants to create another listenable object. We could provide a |
Thinking about it, this has the added benefit of letting you compose listenable objects that can be shared among several stores as well. var theTide = Reflux.all(timeStore, stopWatchStore, waveStore);
// later in other stores
var clockStore = Reflux.createStore({
init: function() {
this.listenTo(theTide, this.theTideCallback);
},
theTideCallback: function() { /* ... */ }
});
var clockDebugStore = Reflux.createStore({
init: function() {
if (debugIsOn) {
this.listenTo(theTide, this.debugCallback);
}
},
debugCallback: function() {
console.log(arguments);
}
}); Reuseable |
Is merged into #34 |
I'd like to propose an alternative to the
waitFor
function to something that makes more sense in a data flow pattern. As described with #18, there are occasions where you're interested in data coming in parallel. The API should be something as simple as a join function (name somewhat inspired by the parallel workflow concept):It would be awesome if we didn't need to pull in a promises library dependency for this.
Please do let me know if we can improve this API before implementing it.
The text was updated successfully, but these errors were encountered: