cyrilluce / saga-duck

extensible and composable duck for redux-saga
MIT License
98 stars 15 forks source link

feat: allow redux store enhancers #4

Closed cha0s closed 5 years ago

cha0s commented 5 years ago

DuckRuntime allows passing in middlewares as a rest parameter. However, this is not flexible enough for all uses.

applyMiddleware is a store enhancer. I understand the motivation behind automatically applying sagaMiddleware, so the case for keeping middlewares is good. However, there is no good way to compose any other store enhancers when constructing DuckRuntime.

This PR changes DuckRuntime's constructor's function signature from accepting middlewares as a rest parameter to accepting middlewares as a second optional array parameter, and accepting enhancers as a third optional array parameter.

Store enhancers are now composed after the applyMiddleware enhancer which is constructed as normal.

NB: I also refactored the createReduxStore call, as it was non-idiomatic and would become overly complicated with the introduction of store enhancers.

cha0s commented 5 years ago

I also noticed that the build changed a lot of whitespace, so this link makes it easier to see the "real" changeset: https://github.com/cyrilluce/saga-duck/pull/4/files?utf8=%E2%9C%93&diff=unified&w=1

cyrilluce commented 5 years ago

Hi cha0s, cause I can't modify your pull request, I have commit a compatible version of enhancers feature, Thanks for your contribution!