Make createStoreBase less opinionated by moving checks into coreEnhancer #1706
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following up on my comment from #1702, this PR makes
createStoreBase
less opinionated by moving certain invariants (actions must be plain objects; actions must have type field) into acoreEnhancer
that is applied automatically bycreateStore
. This allows for a future in whichcreateStoreBase
(or whatever we end up naming it) can be exported separately, providing a cleaner integration point for userland experiments and alternativecreateStore
APIs that may want to opt-out of those assumptions that, while they may make sense for the majority of Redux consumers, aren't essential to the nature of Redux.With this separation,
createStore
is now almost exclusively concerned with subscriptions. I like this because it should make all parties happier: tinkerers can opt-out of "conveniences" that they don't like (such as the INIT action) without having to rewrite any subscription logic, which in turn makes the barrier to adding more conveniences tocreateStore
lower. This is similar in spirit to how we currently treat combineReducers: if you don't like how it works, you don't have to use it.