Skip to content

Conversation

@wbuchwalter
Copy link
Member

No description provided.

@wbuchwalter wbuchwalter mentioned this pull request Aug 20, 2015
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

absolutely...

@wbuchwalter
Copy link
Member Author

Fixed

Copy link
Member

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]);
  }])

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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!

Copy link
Member

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.

wbuchwalter added a commit that referenced this pull request Aug 20, 2015
Store is now created by ngRedux (allows DI in middleware)
@wbuchwalter wbuchwalter merged commit 7f53228 into master Aug 20, 2015
@wbuchwalter wbuchwalter deleted the 1.0.0 branch August 20, 2015 22:41
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.

3 participants