danielr18 / connected-next-router

A Redux binding for Next.js Router compatible with Next.js.
MIT License
109 stars 30 forks source link

Using in reducer #18

Closed stephane-r closed 5 years ago

stephane-r commented 5 years ago

Hello Daniel !

Is it possible to use your module from reducer switch ? For example :

const apiMiddleware = store => next => action => {
  next(action);

  switch (action.type) {
    case LOGIN_THROUGH_API:
      console.log('callApi ...');
      // Push to new route
      break;
  }
};

Thank you :muscle:

danielr18 commented 5 years ago

It should be possible, you could dispatch a navigation action in the middleware.

You might find this useful: https://stackoverflow.com/questions/51186205/how-to-dispatch-actions-from-redux-middleware-in-correct-order

danielr18 commented 5 years ago

Closed due to inactivity.