-
Notifications
You must be signed in to change notification settings - Fork 175
Store is now created by ngRedux (allows DI in middleware) #5
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
Conversation
src/components/ngRedux.js
Outdated
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.
should this be:
invariant(
isFunction(reducer),
'The reducer parameter passed to createStoreWith must be a Function. Instead received %s.',
typeof reducer
);noticed a similar error just below here, and in connector also. Ends up having the error be received undefined even if passing in object/string/etc.
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.
absolutely...
|
Fixed |
src/components/ngRedux.js
Outdated
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.
_ is undefined
but when changing it to typeof middleware === string, I was able to get it working.
Made a simple log middleware that used angular $log instead, and was able to get things working.
.factory('logger', ['$log', function ($log) {
return store => next => action => {
$log.log('dispatching', action);
let result = next(action);
$log.log('next state', store.getState());
return result;
};
}])
.config(['$ngReduxProvider', ($ngReduxProvider) => {
//let createStoreWithMiddleware = applyMiddleware(apiMiddleware, logger, thunk)(createStore);
//let store = createStoreWithMiddleware(reducers);
//$ngReduxProvider.setReduxStore(store);
$ngReduxProvider.createStoreWith(reducers, [apiMiddleware, 'logger', 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.
Hmm that's weird, I added lodash to the package.json in this PR, maybe you forgot to redo npm install?
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.
missing an import 'lodash';, added that and it worked.
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.
Allright, sorry for all this errors, I didn't had time to run my code yesterday.
I removed lodash, it was a bit overkill for a typeof.
I will merge and publish by midday (EST).
Thanks!
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.
No problem, happy to help.
Thanks for making this change, redux + ng-redux is looking really promising for a project that I'm just starting.
Store is now created by ngRedux (allows DI in middleware)
No description provided.