Skip to content

Commit 5555ab0

Browse files
authored
Merge branch 'master' into release/4.0.0
2 parents e7b46cb + f07cdc0 commit 5555ab0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Creates the Redux store, and allow `connect()` to access it.
135135
#### Arguments:
136136
* `reducer` \(*Function*): A single reducer composed of all other reducers (create with redux.combineReducer)
137137
* [`middlewares`] \(*Function[]*): Optional, An array containing all the middleware that should be applied. Functions and strings are both valid members. String will be resolved via Angular, allowing you to use dependency injection in your middlewares.
138-
* [`storeEnhancers`] \(*Function[]*): Optional, this will be used to create the store, in most cases you don't need to pass anything, see [Store Enhancer official documentation.](http://rackt.github.io/redux/docs/Glossary.html#store-enhancer)
138+
* [`storeEnhancers`] \(*Function[]*): Optional, this will be used to create the store, in most cases you don't need to pass anything, see [Store Enhancer official documentation.](https://github.com/reactjs/redux/blob/master/docs/Glossary.md#store-enhancer)
139139
* [`initialState`] \(*Object*): Optional, the initial state of your Redux store.
140140

141141

Diff for: index.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Unsubscribe } from 'redux';
2+
13
declare namespace ngRedux {
24
export interface Reducer extends Function {
35
(state: any, action: any): any;
@@ -21,7 +23,7 @@ declare namespace ngRedux {
2123
replaceReducer(nextReducer: Reducer): void;
2224
dispatch(action: any): any;
2325
getState(): any;
24-
subscribe(listener: Function): Function;
26+
subscribe(listener: Function): Unsubscribe;
2527
connect(
2628
mapStateToTarget: (state: any) => Object,
2729
mapDispatchToTarget?: Object | ((dispatch: Function) => Object)
@@ -35,4 +37,4 @@ declare namespace ngRedux {
3537

3638
declare var ngRedux: string;
3739
export as namespace ngRedux;
38-
export = ngRedux;
40+
export default ngRedux;

Diff for: src/components/ngRedux.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export default function ngReduxProvider() {
4646

4747
_reducer = reducer;
4848
_reducerIsObject = isObject(reducer);
49-
_storeEnhancers = storeEnhancers;
49+
_storeEnhancers = storeEnhancers || [];
5050
_middlewares = middlewares || [];
51-
_initialState = initialState;
51+
_initialState = initialState || {};
5252
};
5353

5454
this.$get = ($injector) => {
@@ -64,7 +64,7 @@ export default function ngReduxProvider() {
6464

6565
const resolvedStoreEnhancer = map(_storeEnhancers, resolveStoreEnhancer);
6666

67-
if(_reducerIsObject) {
67+
if (_reducerIsObject) {
6868
const getReducerKey = key => isString(_reducer[key])
6969
? $injector.get(_reducer[key])
7070
: _reducer[key];
@@ -80,14 +80,14 @@ export default function ngReduxProvider() {
8080
_reducer = combineReducers(reducersObj);
8181
}
8282

83-
const finalCreateStore = resolvedStoreEnhancer ? compose(...resolvedStoreEnhancer)(createStore) : createStore;
84-
85-
//digestMiddleware needs to be the last one.
83+
// digestMiddleware needs to be the last one.
8684
resolvedMiddleware.push(digestMiddleware($injector.get('$rootScope')));
8785

88-
const store = _initialState
89-
? applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer, _initialState)
90-
: applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer);
86+
// combine middleware into a store enhancer.
87+
const middlewares = applyMiddleware(...resolvedMiddleware);
88+
89+
// compose enhancers with middleware and create store.
90+
const store = createStore(_reducer, _initialState, compose(...resolvedStoreEnhancer, middlewares));
9191

9292
const mergedStore = assign({}, store, { connect: Connector(store) });
9393

0 commit comments

Comments
 (0)