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

Projects
None yet
2 participants
@borisirota

borisirota commented Nov 21, 2016

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

Thanks

@zalmoxisus

This comment has been minimized.

Show comment
Hide comment
@zalmoxisus

zalmoxisus Nov 21, 2016

Owner

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

Owner

zalmoxisus commented Nov 21, 2016

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

@borisirota

This comment has been minimized.

Show comment
Hide comment
@zalmoxisus

This comment has been minimized.

Show comment
Hide comment
@zalmoxisus

zalmoxisus Nov 22, 2016

Owner

@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.

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

This comment has been minimized.

Show comment
Hide comment
@borisirota

borisirota Nov 22, 2016

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

borisirota commented Nov 22, 2016

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

@zalmoxisus

This comment has been minimized.

Show comment
Hide comment
@zalmoxisus

zalmoxisus Nov 22, 2016

Owner

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

Owner

zalmoxisus commented Nov 22, 2016

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