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

Fix compose() to have a less surprising API #669

Merged
merged 1 commit into from Sep 1, 2015
Merged

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Sep 1, 2015

This fixes the embarrassing mishap that compose() API was.
As suggested by @jlongster, now it is a proper compose() you'd find in Lodash or Underscore:

it('composes from right to left', () => {
  const double = x => x * 2;
  const square = x => x * x;
  expect(compose(square)(5)).toBe(25);
  expect(compose(square, double)(5)).toBe(100);
  expect(compose(double, square, double)(5)).toBe(200);
});

In terms of usage, if your code looked like this:

const finalCreateStore = compose(
  applyMiddleware(stuff),
  devTools(),
  somethingElse(),
  createStore
);

It will now look like this:

const finalCreateStore = compose(
  applyMiddleware(stuff),
  devTools(),
  somethingElse()
)(createStore);

This is a breaking change, and thus goes on wip-2.0 branch.

This was referenced Sep 1, 2015
gaearon added a commit that referenced this pull request Sep 1, 2015
Fix compose() to have a less surprising API
@gaearon gaearon merged commit e45d9ff into wip-2.0 Sep 1, 2015
@gaearon gaearon deleted the fix-compose branch September 1, 2015 00:19
ghengeveld added a commit to ghengeveld/redux-localstorage that referenced this pull request Sep 2, 2015
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.

None yet

1 participant