Skip to content
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

time travel isn't working when using the redux-batched-subscribe store enhancer #261

Closed
borisirota opened this issue Nov 21, 2016 · 5 comments

Comments

@borisirota
Copy link

Hi, any idea why the time travel isn't working when using the redux-batched-subscribe store enhancer ?

Thanks

@zalmoxisus
Copy link
Owner

Hi. Could you please provide an example repo or jsfiddle? I'd look into it.

@borisirota
Copy link
Author

@zalmoxisus
Copy link
Owner

zalmoxisus commented Nov 22, 2016

@borisirota, thanks for the example.

There's no problems with redux-batched-subscribe, just the orders of the enhancers matters. So, time travelling actually works, but redux-batched-subscribe is not aware of that action (and react-redux listener is not called). To get React updated with those changes you have to emit another action.

The solution is not to use composeWithDevTools, which assures the extension's enhancer to be the last in compose (which is not the case of redux-batched-subscribe), but to use it like so:

  const store = createStore(reducer, preloadedState, compose(
    // applyMiddleware(thunk),
    window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : noop => noop,
    batchedSubscribe((notify) => notify())
  ));

So redux-batched-subscribe will be after the extension's enhancer and will be aware of its actions.

Note that there will be no need for that noop function in the next version of Redux thanks to reduxjs/redux#2073.

@borisirota
Copy link
Author

it works ! great ! thanks a lot !!! 👍

@zalmoxisus
Copy link
Owner

You're welcome. Added a note about it in Troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants