HenrikJoreteg / redux-bundler

Compose a Redux store out of smaller bundles of functionality.
https://reduxbundler.com
583 stars 46 forks source link

Need a way to disable reactors temporarily #49

Closed ananthhh closed 4 years ago

ananthhh commented 5 years ago

I use to do time travel debugging to check the UI at a specific state. I don't want reactors to change the state when I try to do this. Is there any hidden way to do this? I couldn't find anything in the documentation.

Thanks!

HenrikJoreteg commented 5 years ago

hey @ananthhh. So, there isn't currently a way to just turn it off at runtime, but... i don't know if you've seen this but there are two ways to compose your bundles into a store. There's composeBundlesRaw and composeBundles

The only difference is that composeBundles includes a few things by default, you can see that here:

https://github.com/HenrikJoreteg/redux-bundler/blob/master/src/index.js#L28-L42

So, you can opt to just not include the reactors bundle and none of those reactors will fire. Hope that helps.

ananthhh commented 5 years ago

Thanks for the info @HenrikJoreteg A way to disable reactors runtime will be more helpful. If you are fine, I will work on this feature myself and send a PR?

HenrikJoreteg commented 5 years ago

@ananthhh I could see that being useful, yeah. Before you build anything, how would you propose to implement it?

ananthhh commented 5 years ago

Same like how we enable/disable debug bundle. We can have a variable stored in localStorage. If it's there and set to something truthy, then we will disable reactors. Makes sense?

HenrikJoreteg commented 5 years ago

@ananthhh yeah, i could see that working. Ideally, though, for time travel debugging you'd have a way for the app to know it was currently time traveling not trigger the next thing just yet. The other challenge is that so many of those things are time-dependent. Really, in thinking about this, the app-time bundle should have a normal reducer and a "doDispatchIdle" that actually calls Date.now without that, the state stored in reducers during time-travel will be all wonky.

HenrikJoreteg commented 4 years ago

A recent release allows you to pass a function to createReactorBundle to enable/disable individual reactors. It was mainly intended to allow stopping misbehaving reactors that get stuck in a loop, etc. But I think that probably covers this scenario also. Let me know if you think otherwise. I also have some plans for improving the app time bundle to address some of the time-based stuff when time traveling.