Skip to content

Commit d6b7d1e

Browse files
committed
Describe new extension methods
1 parent aed4dce commit d6b7d1e

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@
5757
## Documentation
5858

5959
- [FAQ](docs/FAQ.md)
60-
- [API](docs/API.md)
60+
- API
6161
- [Apply as a Redux store enhancer](docs/API/Arguments.md#windowdevtoolsextensionconfig)
6262
- [Create Redux store right in the extension](docs/API/Arguments.md#windowdevtoolsextensionreducer-preloadedstate-config)
63+
- [Communicate with the extension directly](docs/API/Methods.md)
64+
- [open](docs/API/Methods.md#windowdevtoolsextensionopenposition)
65+
- [notifyErrors](docs/API/Methods.md#windowdevtoolsextensionnotifyerrorsonerror)
66+
- [send](docs/API/Methods.md#windowdevtoolsextensionlistenonmessage-instanceid)
67+
- [connect](docs/API/Methods.md#windowdevtoolsextensionconnectconfig)
68+
- [disconnect](docs/API/Methods.md#windowdevtoolsextensiondisconnect)
6369

6470
## Videos
6571

docs/API/Methods.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Communicate with the extension directly
2+
3+
Use the following methods of `window.devToolsExtension`:
4+
5+
- [open](#windowdevtoolsextensionopenposition)
6+
- [notifyErrors](#windowdevtoolsextensionnotifyerrorsonerror)
7+
- [send](#windowdevtoolsextensionlistenonmessage-instanceid)
8+
- [connect](#windowdevtoolsextensionconnectconfig)
9+
- [disconnect](#windowdevtoolsextensiondisconnect)
10+
11+
### window.devToolsExtension.open([position])
12+
13+
Open monitor window.
14+
15+
##### Arguments
16+
17+
- [`position`] *String* - window position: `left`, `right`, `bottom`. Also can be `panel` to [open it in a Chrome panel](../docs/FAQ.md#how-to-keep-devtools-window-focused-all-the-time-in-a-chrome-panel). Or `remote` to [open remote monitor](..//docs/FAQ.md#how-to-get-it-work-with-webworkers-react-native-hybrid-desktop-and-server-side-apps). By default is `left`.
18+
19+
### window.devToolsExtension.notifyErrors([onError])
20+
21+
Show notifications for uncaught exceptions.
22+
23+
##### Arguments
24+
25+
- [`onError`] *Function* to call when there's an exceptions.
26+
27+
### window.devToolsExtension.send(action, state, [shouldStringify, instanceId])
28+
29+
Send a new action and state manually to be shown on the monitor.
30+
31+
##### Arguments
32+
33+
- `action` *String* (action type) or *Object* with required `type` key.
34+
- `state` *any* - usually object to expand.
35+
- [`shouldStringify`] *Boolean* - indicates whether to serialize `action` and `state`.
36+
- [`instanceId`] *String* - instance id for which to attach the log.
37+
38+
### window.devToolsExtension.listen(onMessage, instanceId)
39+
40+
Send a new action and state manually to be shown on the monitor.
41+
42+
##### Arguments
43+
44+
- `onMessage` *Function* to call when there's an action form the monitor.
45+
- `instanceId` *String* - instance id for which to handle actions.
46+
47+
### window.devToolsExtension.connect([config])
48+
49+
##### Arguments
50+
51+
- [`config`] *Object* intended to be the same as for [Redux store enhancer](Arguments.md#windowdevtoolsextensionconfig). For now only `instanceId` should be specified.
52+
53+
##### Returns
54+
*Object* containing the following methods:
55+
56+
- `subscribe(listener)` - adds a change listener. It will be called any time an action is dispatched form the monitor.
57+
- `unsubscribe()` - unsubscribes the change listener. You can use [window.devToolsExtension.disconnect](#windowdevtoolsextensiondisconnect) to remove all listeners.
58+
- `send(action, state)` - sends a new action and state manually to be shown on the monitor.
59+
60+
[See the example for an example on usage](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/examples/react-counter-messaging/components/Counter.js).
61+
62+
### window.devToolsExtension.disconnect()
63+
64+
Remove extensions listener and disconnect extensions background script connection.

0 commit comments

Comments
 (0)