Skip to content

Enforce reducer type in handleAction#131

Closed
globalchubby wants to merge 0 commit intov1.0.0from
hygiene/check-reducers
Closed

Enforce reducer type in handleAction#131
globalchubby wants to merge 0 commit intov1.0.0from
hygiene/check-reducers

Conversation

@globalchubby
Copy link
Copy Markdown
Contributor

@globalchubby globalchubby 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.

@globalchubby
Copy link
Copy Markdown
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
Copy Markdown
Member

timche commented Oct 6, 2016

Yep, changed here as well.

@globalchubby
Copy link
Copy Markdown
Contributor Author

Note to self: use invariant here as well.

Comment thread src/handleAction.js Outdated
? [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
Copy Markdown
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.

2 participants