l.js const { gToolbox, gHeapAnalysesClient } = window; root = document.querySelector("#app"); store = Store(); const app = createElement(App, { toolbox: gToolbox, commands, heapWorker: gHeapAnalysesClient, }); const provider = createElement(Provider, { store }, app); ReactDOM.render(provider, root); unsubscribe = store.subscribe(onStateChange); // Exposed for tests. window.gStore = store; }; const updateFront = front => { store.dispatch(updateMemoryFront(front)); }; const destroy = function () { // Prevents any further action from being dispatched store.dispatch(START_IGNORE_ACTION); const ok = ReactDOM.unmountComponentAtNode(root); assert( ok, "Should successfully unmount the memory tool's top level React component" ); unsubscribe(); }; // Current state let isHighlighted; /** * Fired on any state change, currently only handles toggling * the highlighting of the tool when recording allocations. */ function onStateChange() { const { gToolbox } = window; const isRecording = store.getState().allocations.recording; if (isRecording === isHighlighted) { return; } if (isRecording) { gToolbox.highlightTool("memory"); } else { gToolbox.unhighlightTool("memory"); } isHighlighted = isRecording; } module.exports = { initialize, updateFront, destroy }; PK