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

adding join methods #92

Merged
merged 4 commits into from
Oct 4, 2014
Merged

adding join methods #92

merged 4 commits into from
Oct 4, 2014

Conversation

krawaller
Copy link
Contributor

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:

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:

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.

@spoike spoike added this to the 0.1.13 milestone Oct 2, 2014
@spoike
Copy link
Member

spoike commented Oct 2, 2014

Sweet! Will add this to the 0.1.13 release.

spoike added a commit that referenced this pull request Oct 4, 2014
@spoike spoike merged commit c482b64 into reflux:master Oct 4, 2014
@krawaller krawaller deleted the aggregates branch October 5, 2014 06:15
@KyleAMathews
Copy link
Contributor

Great stuff people!

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.

3 participants