-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Breaking API changes for 1.0 #195
Conversation
9a0bc7a
to
634d18e
Compare
Naming: * “Stateless Stores” are now called reducers. (#137 (comment)) * The “Redux instance” is now called “The Store”. (#137 (comment)) * The dispatcher is removed completely. (#166 (comment)) API changes: * <s>`composeStores`</s> is now `composeReducers`. * <s>`createDispatcher`</s> is gone. * <s>`createRedux`</s> is now `createStore`. * `<Provider>` now accepts `store` prop instead of <s>`redux`</s>. * The new `createStore` signature is `createStore(reducer: Function | Object, initialState: any, middlewares: Array | ({ getState, dispatch }) => Array)`. * If the first argument to `createStore` is an object, `composeReducers` is automatically applied to it. * The “smart” middleware signature changed. It now accepts an object instead of a single `getState` function. The `dispatch` function lets you “recurse” the middleware chain and is useful for async: #113 (comment). Correctness changes: * The `dispatch` provided by the default thunk middleware now walks the whole middleware chain. * It is enforced now that raw Actions at the end of the middleware chain have to be plain objects. * Nested dispatches are now handled gracefully. (#110) Internal changes: * The object in React context is renamed from <s>`redux`</s> to `store`. * Some tests are rewritten for clarity, focus and edge cases. * Redux in examples is now aliased to the source code for easier work on master.
634d18e
to
e426039
Compare
Released on NPM as |
🎉 :) |
@@ -1,5 +1,5 @@ | |||
import React from 'react'; | |||
import { bindActionCreators } from 'redux'; | |||
import { bindActionCreators } from 'redux/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, this slipped in by mistake when copy-pasting.
Yay! Looks good! I've been wondering if Consider another common way of composing reducers, which is to apply each one of them in sequence: (...reducers) => (prevState, action) =>
reducers.reduce(
(state, r) => r(state, action),
prevState
); This could also be named Maybe we should think of a more specific name? Don't have any suggestions right now, but I wonder what everyone else's thoughts are. |
@acdlite Any precedents in other libraries' APIs? |
|
||
return recurse; | ||
}; | ||
export default function thunkMiddleware({ dispatch, getState }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the name "thunk" come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as in so? https://en.wikipedia.org/wiki/Thunk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon one step forward, great work! 👍 |
return { | ||
dispatch: cookedDispatch, | ||
subscribe: ::store.subscribe, | ||
getState: ::store.getState, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m curious why a second ::store.getState
function is created instead of reusing the one from #L20?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overlooked this :-). No real reason
…menter Modify test case ID generation for reducer changing
|
I like combine. |
Update counter example to recent react-redux
Unsubscribing during a dispatch would change the listeners array. However that causes the next listener not to fire.
Fixes #461 - Copy listeners array, so subscribes can't affect the loop.
Add “real world” example
…mple Update real world example to remove ES7
Fix syntax error in Object.assign in real world example
This changes 'on' to 'one' in the string 'Specify on of the exported Schemas.'
Real World Example - Fix typo in API middleware error string
Tweak example conventions
Add a simple async example
2.5 (insanely hectic for you)months from "Initial Commit" to "1.0" is kind of crazy... Nice work :) |
Naming
API changes
is nowcomposeStores
composeReducers
.is gone.createDispatcher
is nowcreateRedux
createStore
.<Provider>
now acceptsstore
prop instead of.redux
createStore
signature iscreateStore(reducer: Function | Object, initialState: any, middlewares: Array | ({ getState, dispatch }) => Array)
.createStore
is an object,composeReducers
is automatically applied to it.getState
function. Thedispatch
function lets you “recurse” the middleware chain and is useful for async: Time travel #113 (comment).Correctness changes
dispatch
provided by the default thunk middleware now walks the whole middleware chain.Internal changes
toredux
store
.