Skip to content

Adjust store creation to resolve issue with redux-first-router #166

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

Merged
merged 1 commit into from
Sep 25, 2017
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
18 changes: 9 additions & 9 deletions src/components/ngRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default function ngReduxProvider() {

_reducer = reducer;
_reducerIsObject = isObject(reducer);
_storeEnhancers = storeEnhancers
_storeEnhancers = storeEnhancers || [];
_middlewares = middlewares || [];
_initialState = initialState;
_initialState = initialState || {};
};

this.$get = ($injector) => {
Expand All @@ -54,7 +54,7 @@ export default function ngReduxProvider() {

const resolvedStoreEnhancer = map(_storeEnhancers, resolveStoreEnhancer);

if(_reducerIsObject) {
if (_reducerIsObject) {
const getReducerKey = key => isString(_reducer[key])
? $injector.get(_reducer[key])
: _reducer[key];
Expand All @@ -70,14 +70,14 @@ export default function ngReduxProvider() {
_reducer = combineReducers(reducersObj);
}

const finalCreateStore = resolvedStoreEnhancer ? compose(...resolvedStoreEnhancer)(createStore) : createStore;

//digestMiddleware needs to be the last one.
// digestMiddleware needs to be the last one.
resolvedMiddleware.push(digestMiddleware($injector.get('$rootScope')));

const store = _initialState
? applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer, _initialState)
: applyMiddleware(...resolvedMiddleware)(finalCreateStore)(_reducer);
// combine middleware into a store enhancer.
const middlewares = applyMiddleware(...resolvedMiddleware);

// compose enhancers with middleware and create store.
const store = createStore(_reducer, _initialState, compose(...resolvedStoreEnhancer, middlewares));

return assign({}, store, { connect: Connector(store) });
};
Expand Down