Skip to content

Commit 322156d

Browse files
committed
Send also the liftedState for connected devtools
Related to #77.
1 parent d6b7d1e commit 322156d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/API/Methods.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ Send a new action and state manually to be shown on the monitor.
4848

4949
##### Arguments
5050

51-
- [`config`] *Object* intended to be the same as for [Redux store enhancer](Arguments.md#windowdevtoolsextensionconfig). For now only `instanceId` should be specified.
51+
- [`config`] *Object* intended to be the same as for [Redux store enhancer](Arguments.md#windowdevtoolsextensionconfig). For now only `instanceId` and `shouldStringify` should be specified.
5252

5353
##### Returns
5454
*Object* containing the following methods:
5555

5656
- `subscribe(listener)` - adds a change listener. It will be called any time an action is dispatched form the monitor.
5757
- `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.
58+
- `send(action, state)` - sends a new action and state manually to be shown on the monitor. If action is `null` then we suppose we send `liftedState`.
5959

6060
[See the example for an example on usage](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/examples/react-counter-messaging/components/Counter.js).
6161

src/browser/extension/utils/contentScriptMsg.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,20 @@ export function toContentScript(message, shouldStringify) {
2424
}
2525

2626
export function sendMessage(action, state, shouldStringify, id) {
27-
toContentScript({
28-
type: 'ACTION',
29-
action: typeof action === 'object' ? action : { type: action },
27+
const message = {
3028
payload: state,
3129
source: '@devtools-page',
3230
name: document.title,
3331
id
34-
}, shouldStringify);
32+
};
33+
if (action) {
34+
message.type = 'ACTION';
35+
message.action = typeof action === 'object' ? action : { type: action };
36+
} else {
37+
message.type = 'STATE';
38+
}
39+
40+
toContentScript(message, shouldStringify);
3541
}
3642

3743
function handleMessages(event) {

0 commit comments

Comments
 (0)