-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(#285): add composeWithStateSync to resolve issues with enhancer order #296
Conversation
Thanks for the contribution! We will try to take a look at the change in next few days, you could also add some info into the README file, like you mentioned. I've also started a docs page for the project ( @slapbox if you have some time, you might also take a look at this branch & try it with your issue #294 and |
Friggin' Windows... Builds fine on Linux, will update soon. |
@Superjo149 there's no code changes needed on our end to take advantage of these changes, right? Unfortunately it doesn't seem to remedy the issue with Redux Saga. I took a look at how to setup RxJS and it looks very similar to setting up sagas. Can you share the part of your store configuration where you're applying your enhancers and middlewares so I can compare it with our setup? I also tried importing |
@slapbox There is some kind of code change required, yes. I will properly document this tomorrow along with the tests. But this is the jist. The error sounds like your are using both the old API and the compose function. Current approach:Just selected the main process here as an example. const middleware = applyMiddleware(countMiddleware)
const enhancer = compose(middleware, mainStateSyncEnhancer())
const store = createStore(reducer, defaultState, enhancer) Approach with multiple enhancers (Saga middleware,... etc) using composeWithStateSync:
const middleware = applyMiddleware(countMiddleware)
const enhancer = composeWithStateSync(middleware)
const store = createStore(reducer, defaultState, enhancer) |
@Superjo149 thanks so much for your help, that makes perfect sense now and I can confirm that everything seems to work properly! Not only a fix, but a further streamlining of an already great API; wow, great work! PS: Is there a way to get Redux Devtools working with this too? |
Oh, you can just wrap compose functions around compose functions. Never knew that, so that's the solution for Redux Devtools in case anyone is lurking this thread. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks exciting! I believe this is the right direction, and will get us closer to releasing stable v2 version, thanks a lot for all the hard work you put into figuring out how to implement this 👍🏻
🎉 This PR is included in version 2.0.0-alpha.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Glad I could contribute to this 🎉 |
As discussed in #285. Added a new
composeWithStateSync
function which mimics the composer function and should replace that function when using more than one enhancer. When using one enhancer, the other API is still the same.To accommodate this, I have also added 2 more things:
preventActionReplay
was added to the options because inextensionCompose()
we re-use thestateSyncEnhancer
, but we do not want the actions to start forwarding there because then it will not pick up the ones dispatched by the middleware. We rather want them to start forwarding in the last part of the chain, henceforwardActionEnhancer
. This is also possible with denyList, but I thought this was cleaner. WDYT?stateSyncEnhancer
which can wrap around the process specific enhancer to do the same thing.Will see if I can write a test for it tomorrow. Do you want me to go ahead and update the README already as well @matmalkowski ?