Skip to content

Conversation

@gaearon
Copy link
Contributor

@gaearon gaearon commented Jun 30, 2015

Naming

API changes

  • composeStores is now composeReducers.
  • createDispatcher is gone.
  • createRedux is now createStore.
  • <Provider> now accepts store prop instead of redux.
  • 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: Time travel #113 (comment).

Correctness changes

Internal changes

  • The object in React context is renamed from redux 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.

This was referenced Jun 30, 2015
@gaearon gaearon force-pushed the breaking-changes-1.0 branch from 9a0bc7a to 634d18e Compare June 30, 2015 21:41
@gaearon
Copy link
Contributor Author

gaearon commented Jun 30, 2015

This PR supersedes #166, #119, and #120, and brings us much closer to 1.0 (#164).

The missing pieces for 1.0 are more strict composeReducers (#193), new docs (#140), and a more convenient action creator binding API (#86), if we are certain that we need it.

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.
@gaearon gaearon force-pushed the breaking-changes-1.0 branch from 634d18e to e426039 Compare June 30, 2015 21:52
@gaearon
Copy link
Contributor Author

gaearon commented Jun 30, 2015

Released on NPM as 1.0.0-alpha.

@dariocravero
Copy link
Contributor

🎉 :)

Copy link
Contributor Author

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.

@acdlite
Copy link
Collaborator

acdlite commented Jun 30, 2015

Yay! Looks good!

I've been wondering if composeReducers() is really the best name for that function. The name is very generic, whereas its implementation is very specific.

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 composeReducers(). (I'd actually argue this is better fit for the name.)

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.

@gaearon
Copy link
Contributor Author

gaearon commented Jun 30, 2015

@acdlite Any precedents in other libraries' APIs?

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@emmenko
Copy link
Contributor

emmenko commented Jul 1, 2015

@gaearon one step forward, great work! 👍

Copy link
Contributor

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?

Copy link
Contributor Author

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
@rpominov
Copy link

rpominov commented Jul 1, 2015

I've been wondering if composeReducers() is really the best name for that function.
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.

combineReducers() maybe?

@gaearon
Copy link
Contributor Author

gaearon commented Jul 1, 2015

I like combine.

gaearon and others added 25 commits August 10, 2015 21:38
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.
…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
gaearon added a commit that referenced this pull request Aug 14, 2015
@gaearon gaearon merged commit 6d0107e into master Aug 14, 2015
@ghost
Copy link

ghost commented Aug 14, 2015

2.5 (insanely hectic for you)months from "Initial Commit" to "1.0" is kind of crazy... Nice work :)

@gaearon gaearon deleted the breaking-changes-1.0 branch August 14, 2015 13:31
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.