joshburgess / redux-most

Most.js based middleware for Redux. Handle async actions with monadic streams & reactive programming.
https://www.npmjs.com/package/redux-most
MIT License
139 stars 14 forks source link

"Dispatching while constructing middleware" error with Redux ^4.0.0 #30

Closed mbohgard closed 6 years ago

mbohgard commented 6 years ago

When using the createEpicMiddleware with Redux applyMiddleware I get an error when creating the store: Uncaught Error: Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch. redux-most can't be used with Redux ^4.0.0 before this is fixed somehow.

joshburgess commented 6 years ago

Thanks. This is because of the init action I'm dispatching. I had an idea for it originally, but never ended up making use of it. So, I will probably just remove it altogether...... but will need to make this a breaking change just in case anyone was watching it in their apps as a signal to do something.

If you'd like to add this to your https://github.com/joshburgess/redux-most/pull/29 PR, I will merge it together. If not, I can do it.

It's basically just deleting the EPIC_BEGIN constant from the constants file + the epicBegin action creator + removing the import & this middlewareApi.dispatch(epicBegin()) line in createEpicMiddleware.

mbohgard commented 6 years ago

I can do it. What about the EPIC_END action. Should we get rid of that as well, since there's no EPIC_BEGIN anymore?

joshburgess commented 6 years ago

No, I think that should stay. It's something I borrowed from redux-observable. That one has more of a purpose. It's to use as a trigger for initiating any sort of cleanup work you might want to do when using the replaceEpic method (hot reloading is the most common use case for this, but there are others.)

That one fires only later on. So, it's unrelated to the new code they added in Redux that's causing the error you're seeing. EPIC_BEGIN is fired during the construction phase though.