Skip to content
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

refactor Reflux.all #84

Merged
merged 3 commits into from
Sep 29, 2014
Merged

refactor Reflux.all #84

merged 3 commits into from
Sep 29, 2014

Conversation

krawaller
Copy link
Contributor

This PR refactors the code for Reflux.all.

I found the prior implementation, returning a hacked action, to be a bit dangerous. What we get back is both a listener and a publisher, which means it is really a store! By implementing it as such instead we get shorter code, and we can get rid of the extra hasListener method which was needed earlier since the action was moonlighting as a listener.

As a bonus, by using ListenerMethods.listenTo instead of directly calling PublisherMethods.listen, we get an object which can clean up itself.

Less LOC:s, less debt and headache waiting to happen.

There is an ever so slight API breakage as we no longer get back a functor, but I doubt it was ever used in such a way.

@krawaller krawaller mentioned this pull request Sep 25, 2014
@krawaller
Copy link
Contributor Author

Just realised that listenable aggregation is potentially useful not just for a publisher, so I abstracted out the functionality into ListenerMethods.listenToAggregate(...listenables,callback).

This means that Reflux.all is now just doing this:

var listenables = Array.prototype.slice.call(arguments);
return createStore({
    init: function(){
        this.listenToAggregate.apply(this,listenables.concat("trigger"));
    }
});

spoike added a commit that referenced this pull request Sep 29, 2014
@spoike spoike merged commit 93475e5 into reflux:master Sep 29, 2014
@spoike spoike added this to the 0.1.12 milestone Sep 29, 2014
@krawaller krawaller deleted the refactorall branch October 2, 2014 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants