Skip to content

Commit

Permalink
Send also the liftedState for connected devtools
Browse files Browse the repository at this point in the history
Related to #77.
  • Loading branch information
zalmoxisus committed Jun 1, 2016
1 parent d6b7d1e commit 322156d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/API/Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ Send a new action and state manually to be shown on the monitor.

##### Arguments

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

##### Returns
*Object* containing the following methods:

- `subscribe(listener)` - adds a change listener. It will be called any time an action is dispatched form the monitor.
- `unsubscribe()` - unsubscribes the change listener. You can use [window.devToolsExtension.disconnect](#windowdevtoolsextensiondisconnect) to remove all listeners.
- `send(action, state)` - sends a new action and state manually to be shown on the monitor.
- `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`.

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

Expand Down
14 changes: 10 additions & 4 deletions src/browser/extension/utils/contentScriptMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ export function toContentScript(message, shouldStringify) {
}

export function sendMessage(action, state, shouldStringify, id) {
toContentScript({
type: 'ACTION',
action: typeof action === 'object' ? action : { type: action },
const message = {
payload: state,
source: '@devtools-page',
name: document.title,
id
}, shouldStringify);
};
if (action) {
message.type = 'ACTION';
message.action = typeof action === 'object' ? action : { type: action };
} else {
message.type = 'STATE';
}

toContentScript(message, shouldStringify);
}

function handleMessages(event) {
Expand Down

0 comments on commit 322156d

Please sign in to comment.