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

Enforce reducer type in handleAction #131

Closed
wants to merge 0 commits into from

Conversation

yangmillstheory
Copy link
Contributor

@yangmillstheory yangmillstheory commented Sep 9, 2016

Stop silently coercing bad reducer types; be clear on the API contract.

This is like #129, except for handleAction instead of createAction, so it has breaking changes.


Note that this doesn't make downstream errors happen earlier and more clearly (I checked this in tests in wrong reducer types), it just clarifies and enforces the API contract.

@yangmillstheory
Copy link
Contributor Author

@timche Should we change the base branch to v1.0.0 since this has breaking changes?

@timche timche changed the base branch from master to v1.0.0 October 6, 2016 15:25
@timche
Copy link
Member

timche commented Oct 6, 2016

Yep, changed here as well.

@yangmillstheory
Copy link
Contributor Author

Note to self: use invariant here as well.

? [reducers, reducers]
: [reducers.next, reducers.throw].map(reducer => (isNil(reducer) ? identity : reducer));
if (!isFunction(reducer) && !isPlainObject(reducer)) {
throw new TypeError('Expected reducer to be a function or object with next and throw reducers');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just change this to use invariant and we are good to go ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants