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

Remove getReducer() from Store API #668

Merged
merged 1 commit into from
Aug 31, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/Glossary.md
Original file line number Diff line number Diff line change
@@ -97,7 +97,6 @@ type Store = {
dispatch: Dispatch;
getState: () => State;
subscribe: (listener: () => void) => () => void;
getReducer: () => Reducer;
replaceReducer: (reducer: Reducer) => void;
};
```
@@ -108,7 +107,7 @@ There should only be a single store in a Redux app, as the composition happens o
- [`dispatch(action)`](api/Store.md#dispatch) is the base dispatch function described above.
- [`getState()`](api/Store.md#getState) returns the current state of the store.
- [`subscribe(listener)`](api/Store.md#subscribe) registers a function to be called on state changes.
- [`getReducer()`](api/Store.md#getReducer) and [`replaceReducer(nextReducer)`](api/Store.md#replaceReducer) can be used to implement hot reloading and code splitting. Most likely you won’t use them.
- [`replaceReducer(nextReducer)`](api/Store.md#replaceReducer) can be used to implement hot reloading and code splitting. Most likely you won’t use it.

See the complete [store API reference](api/Store.md#dispatch) for more details.

1 change: 0 additions & 1 deletion docs/api/README.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ This section documents the complete Redux API. Keep in mind that Redux is only c
* [getState()](Store.md#getState)
* [dispatch(action)](Store.md#dispatch)
* [subscribe(listener)](Store.md#subscribe)
* [getReducer()](Store.md#getReducer)
* [replaceReducer(nextReducer)](Store.md#replaceReducer)

### Importing
18 changes: 0 additions & 18 deletions docs/api/Store.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ To create it, pass your root [reducing function](../Glossary.md#reducer) to [`cr
- [`getState()`](#getState)
- [`dispatch(action)`](#dispatch)
- [`subscribe(listener)`](#subscribe)
- [`getReducer()`](#getReducer)
- [`replaceReducer(nextReducer)`](#replaceReducer)

## Store Methods
@@ -118,23 +117,6 @@ handleChange();

<hr>

### <a id='getReducer'></a>[`getReducer()`](#getReducer)

>##### Deprecated

>This API has been [deprecated](https://github.com/rackt/redux/issues/350).
>It will be removed when we find a better solution for this problem.

Returns the reducer currently used by the store to calculate the state.

It is an advanced API. You might only need this if you implement a hot reloading mechanism for Redux.

#### Returns

(*Function*): The store’s current reducer.

<hr>

### <a id='replaceReducer'></a>[`replaceReducer(nextReducer)`](#replaceReducer)

>##### Deprecated
14 changes: 0 additions & 14 deletions src/createStore.js
Original file line number Diff line number Diff line change
@@ -109,18 +109,6 @@ export default function createStore(reducer, initialState) {
return action;
}

/**
* Returns the reducer currently used by the store to calculate the state.
*
* It is likely that you will only need this function if you implement a hot
* reloading mechanism for Redux.
*
* @returns {Function} The reducer used by the current store.
*/
function getReducer() {
return currentReducer;
}

/**
* Replaces the reducer currently used by the store to calculate the state.
*
@@ -136,7 +124,6 @@ export default function createStore(reducer, initialState) {
dispatch({ type: ActionTypes.INIT });
}


// When a store is created, an "INIT" action is dispatched so that every
// reducer returns their initial state. This effectively populates
// the initial state tree.
@@ -146,7 +133,6 @@ export default function createStore(reducer, initialState) {
dispatch,
subscribe,
getState,
getReducer,
replaceReducer
};
}
9 changes: 3 additions & 6 deletions test/createStore.spec.js
Original file line number Diff line number Diff line change
@@ -8,11 +8,10 @@ describe('createStore', () => {
const store = createStore(combineReducers(reducers));
const methods = Object.keys(store);

expect(methods.length).toBe(5);
expect(methods.length).toBe(4);
expect(methods).toContain('subscribe');
expect(methods).toContain('dispatch');
expect(methods).toContain('getState');
expect(methods).toContain('getReducer');
expect(methods).toContain('replaceReducer');
});

@@ -106,8 +105,7 @@ describe('createStore', () => {
text: 'World'
}]);

let nextStore = createStore(reducers.todosReverse);
store.replaceReducer(nextStore.getReducer());
store.replaceReducer(reducers.todosReverse);
expect(store.getState()).toEqual([{
id: 1,
text: 'Hello'
@@ -128,8 +126,7 @@ describe('createStore', () => {
text: 'World'
}]);

nextStore = createStore(reducers.todos);
store.replaceReducer(nextStore.getReducer());
store.replaceReducer(reducers.todos);
expect(store.getState()).toEqual([{
id: 3,
text: 'Perhaps'