Skip to content

Commit

Permalink
Send config to the monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Dec 2, 2016
1 parent dcd346e commit 89dfbe8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/browser/extension/inject/pageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const devToolsExtension = function(reducer, preloadedState, config) {
}, true, true);
}

function relay(type, state, action, nextActionId, shouldInit) {
function relay(type, state, action, nextActionId, libConfig) {
const message = {
type,
payload: filterState(
Expand All @@ -101,19 +101,18 @@ const devToolsExtension = function(reducer, preloadedState, config) {
message.action = !actionSanitizer ? action : actionSanitizer(action.action, nextActionId - 1);
message.maxAge = maxAge;
message.nextActionId = nextActionId;
} else if (shouldInit) {
message.action = action;
message.name = config.name || document.title;
} else if (libConfig) {
message.libConfig = libConfig;
}

toContentScript(message, serializeState, serializeAction);
}

const relayState = throttle((liftedState, actions, shouldInit) => {
const relayState = throttle((liftedState, libConfig) => {
relayAction.cancel();
const state = liftedState || store.liftedStore.getState();
sendingActionId = state.nextActionId;
relay('STATE', state, actions, undefined, shouldInit);
relay('STATE', state, undefined, undefined, libConfig);
}, latency);

const relayAction = throttle(() => {
Expand Down Expand Up @@ -210,7 +209,11 @@ const devToolsExtension = function(reducer, preloadedState, config) {
if (!actionCreators && config.actionCreators) {
actionCreators = getActionsArray(config.actionCreators);
}
relayState(undefined, JSON.stringify(actionCreators), true);
relayState(undefined, {
name: config.name || document.title,
actionCreators: JSON.stringify(actionCreators),
type: 'redux'
});

if (reportId) {
relay('GET_REPORT', reportId);
Expand Down

0 comments on commit 89dfbe8

Please sign in to comment.