-
Notifications
You must be signed in to change notification settings - Fork 1k
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
API for checking whether the monitor is open #145
Comments
There's no such method in our API, but it wouldn't be hard to implement (the only problem is when having more instances in one tab). Could you tell me about your user case? Maybe better to provide a way to check when a monitor action is applied (toggling, moving back and forth, importing the history...) to prevent side effects in this case? Also related to #140. |
You're right, a more granular way of disabling side effects would indeed be preferable. Starting with opening and closing the monitor seems to be the easiest and quickest way for now however. I'm currently using redux-saga and my idea is to combine that functionality with a hook in redux-saga to conditionally disable the processing of side effects. In redux-saga, side effects are not executed immediately, instead they are declared using descriptor objects that are then processed at a later stage. Wrapping all side effects in sagas means one has more control over them, as they can now be intercepted and optionally cancelled. |
Could you share a snippet of how you want to integrate it in sagas? If you prevent all side effects when the extension's monitor is open, that means you'll not be able to use it for logging and remote control, only for dispatching monitors actions. |
In redux-saga you have the option to add a SagaMonitor as part of initializing the saga middleware. In my local fork of redux-saga, I've just added another method to the monitor, that is subsequently invoked in Of course, a better solution would be what Cerebral does and that is to keep track of which side effect caused what output, and only replay the output instead of the side effects when time travelling. A proper solution is still under discussion however, see redux-saga/redux-saga#5 and redux-saga/redux-saga#22. For now though, a hook would do the trick until we have found a better way. |
@rybon, I was thinking about this, and adding to the API a global function like const sagaMiddleware = createSagaMiddleware();
let isMonitoring;
const store = createStore(
reducer,
compose(
applyMiddleware(sagaMiddleware),
window.devToolsExtension && window.devToolsExtension({ isMonitoring })
)
);
sagaMiddleware.run(rootSaga, isMonitoring); Anyway, we want to monitor side effects as well (which I want to implement in the nearest future), so such a solution wouldn't be viable. Better to have something like What do you think? |
Looks alright to start with. I presume |
Yes, it would be a function, which returns Can we just use |
Sure, |
Implemented in A PR with a recipe or an example of usage with sagas would be much appreciated. |
Thanks! An example with my forked redux-saga repo will be forthcoming. |
There's a better way now to prevent side effects from middlewares like redux-saga. See the post for details on how to get it. |
Is it possible to call a method on
window.devToolsExtension
to determine whether the DevTools monitor is currently open or closed? I'd like to use that information to conditionally disable side effects. As far as I know we can only check whetherwindow.devToolsExtension
is available.The text was updated successfully, but these errors were encountered: