redux-dynamic-modules icon indicating copy to clipboard operation
redux-dynamic-modules copied to clipboard

Middlewares with saga

Open Konstantin6487 opened this issue 6 years ago • 2 comments

My module looks like:

export const sagaMiddleware = createSagaMiddleware();

const module = ({
  id: name,
  reducerMap: {
    [name]: reducer,
  },
  middlewares: [middleware, sagaMiddleware],
});

and later sagaMiddleware.run(...); Middlewares apply from left to right, but if i use module with saga's autorun:

const module = ({
  id: name,
  reducerMap: {
    [name]: reducer,
  },
  middlewares: [middleware],
  sagas: [saga],
});

Created sagaMiddleware becomes the head of middlewares list (like middlewares: [sagaMiddleware, middleware]) And it's a problem 🤔

Konstantin6487 avatar Sep 09 '19 09:09 Konstantin6487

Hi @Konstantin6487 Could you describe the issue you are facing in a little more detail? You need your dynamic middleware to execute before the sagas?

abettadapur avatar Oct 01 '19 19:10 abettadapur

I unfortunately don't have a great solution to this problem that doesn't degrade into some kind of order wars (like z-index wars).

Do you have any suggestions on what you think you might want this API to look like?

abettadapur avatar Oct 01 '19 19:10 abettadapur