Note this is advanced API, which you usually don't need to use with Redux enhancer.
Use the following methods of window.__REDUX_DEVTOOLS_EXTENSION__
:
- [
options
] Object - see the available options.
Object containing the following methods:
subscribe(listener)
- adds a change listener. It will be called any time an action is dispatched form the monitor. Returns a function to unsubscribe the current listener.unsubscribe()
- unsubscribes all listeners.send(action, state)
- sends a new action and state manually to be shown on the monitor. If action isnull
then we suppose we sendliftedState
.init(state)
- sends the initial state to the monitor.error(message)
- sends the error message to be shown in the extension's monitor.
Example of usage:
const devTools = window.__REDUX_DEVTOOLS_EXTENSION__.connect(config);
devTools.subscribe((message) => {
if (message.type === 'DISPATCH' && message.state) {
console.log('DevTools requested to change the state to', message.state);
}
});
devTools.init({ value: 'initial state' });
devTools.send('change state', { value: 'state changed' })
See redux enhancer's examle, react example and blog post for more details.
Remove extensions listener and disconnect extensions background script connection. Usually just unsubscribing the listiner inside the connect
is enough.
Send a new action and state manually to be shown on the monitor. It's recommended to use connect
, unless you want to hook into an already created instance.
action
String (action type) or Object with requiredtype
key.state
any - usually object to expand.- [
options
] Object - see the available options. - [
instanceId
] String - instance id for which to include the log. If not specified and not present in theoptions
object, will be the first available instance.
Listen for messages dispatched for specific instanceId
. For most of cases it's better to use subcribe
inside the connect
.
onMessage
Function to call when there's an action form the monitor.instanceId
String - instance id for which to handle actions.
Open the extension's window. This should be conditional (usually you don't need to open extension's window automatically).
- [
position
] String - window position:left
,right
,bottom
. Also can bepanel
to open it in a Chrome panel. Orremote
to open remote monitor. By default isleft
.
When called, the extension will listen for uncaught exceptions on the page, and, if any, will show native notifications. Optionally, you can provide a function to be called when and exception occurs.
- [
onError
] Function to call when there's an exceptions.