From e68a3c988adfdf54c6d6b539e6369a81c01c9205 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 2 Oct 2019 16:02:48 -0700 Subject: [PATCH] Cleaned up event names --- .../src/backend/agent.js | 28 +++++++------- packages/react-devtools-shared/src/bridge.js | 2 +- .../views/Settings/GeneralSettings.js | 8 ++-- .../views/Settings/SettingsContext.js | 37 +++++++++---------- 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index f826a0b6ed21d..37593064a9997 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -126,6 +126,7 @@ export default class Agent extends EventEmitter<{| this._bridge = bridge; + bridge.addListener('enableTraceUpdates', this.enableTraceUpdates); bridge.addListener('getProfilingData', this.getProfilingData); bridge.addListener('getProfilingStatus', this.getProfilingStatus); bridge.addListener('getOwnersList', this.getOwnersList); @@ -149,7 +150,6 @@ export default class Agent extends EventEmitter<{| this.updateAppendComponentStack, ); bridge.addListener('updateComponentFilters', this.updateComponentFilters); - bridge.addListener('updateTraceUpdates', this.updateTraceUpdates); bridge.addListener('viewElementSource', this.viewElementSource); if (this._isProfiling) { @@ -204,6 +204,19 @@ export default class Agent extends EventEmitter<{| return null; } + enableTraceUpdates = (isEnabled: boolean) => { + this._traceUpdatesEnabled = isEnabled; + + toggleTraceUpdatesEnabled(isEnabled); + + for (let rendererID in this._rendererInterfaces) { + const renderer = ((this._rendererInterfaces[ + (rendererID: any) + ]: any): RendererInterface); + renderer.toggleTraceUpdatesEnabled(isEnabled); + } + }; + getProfilingData = ({rendererID}: {|rendererID: RendererID|}) => { const renderer = this._rendererInterfaces[rendererID]; if (renderer == null) { @@ -417,19 +430,6 @@ export default class Agent extends EventEmitter<{| } }; - updateTraceUpdates = (isEnabled: boolean) => { - this._traceUpdatesEnabled = isEnabled; - - toggleTraceUpdatesEnabled(isEnabled); - - for (let rendererID in this._rendererInterfaces) { - const renderer = ((this._rendererInterfaces[ - (rendererID: any) - ]: any): RendererInterface); - renderer.toggleTraceUpdatesEnabled(isEnabled); - } - }; - viewElementSource = ({id, rendererID}: ElementAndRendererID) => { const renderer = this._rendererInterfaces[rendererID]; if (renderer == null) { diff --git a/packages/react-devtools-shared/src/bridge.js b/packages/react-devtools-shared/src/bridge.js index 937374d71025d..73607f3322bb7 100644 --- a/packages/react-devtools-shared/src/bridge.js +++ b/packages/react-devtools-shared/src/bridge.js @@ -94,6 +94,7 @@ type BackendEvents = {| type FrontendEvents = {| clearNativeElementHighlight: [], + enableTraceUpdates: [boolean], getOwnersList: [ElementAndRendererID], getProfilingData: [{|rendererID: RendererID|}], getProfilingStatus: [], @@ -115,7 +116,6 @@ type FrontendEvents = {| stopProfiling: [], updateAppendComponentStack: [boolean], updateComponentFilters: [Array], - updateTraceUpdates: [boolean], viewElementSource: [ElementAndRendererID], // React Native style editor plug-in. diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/GeneralSettings.js b/packages/react-devtools-shared/src/devtools/views/Settings/GeneralSettings.js index 2b039e7ac9437..4e7ce6357c638 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/GeneralSettings.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/GeneralSettings.js @@ -18,12 +18,12 @@ export default function GeneralSettings(_: {||}) { const { appendComponentStack, displayDensity, - traceUpdates, setAppendComponentStack, - setTraceUpdates, setDisplayDensity, setTheme, + setTraceUpdatesEnabled, theme, + traceUpdatesEnabled, } = useContext(SettingsContext); const {supportsTraceUpdates} = useContext(StoreContext); @@ -60,9 +60,9 @@ export default function GeneralSettings(_: {||}) {