Skip to content

Commit

Permalink
Add reload-to-profile for Fusebox (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmondChuiHW authored Oct 16, 2024
1 parent eb757e8 commit 7769586
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion front_end/panels/react_devtools/ReactDevToolsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
window.addEventListener('beforeunload', () => this.#bridge?.shutdown());
}

override dispose(): void {
this.#bridge?.removeListener('reloadAppForProfiling', this.#handleReloadAppForProfiling);
}

ensureInitialized(): void {
if (this.#initializeCalled) {
return;
Expand Down Expand Up @@ -163,10 +167,17 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {

#finishInitializationAndNotify(): void {
this.#bridge = ReactDevTools.createBridge(this.#wall);
this.#store = ReactDevTools.createStore(this.#bridge);
this.#store = ReactDevTools.createStore(this.#bridge, {
supportsReloadAndProfile: true,
});
this.#bridge.addListener('reloadAppForProfiling', this.#handleReloadAppForProfiling);
this.dispatchEventToListeners(Events.InitializationCompleted);
}

#handleReloadAppForProfiling(): void {
SDK.ResourceTreeModel.ResourceTreeModel.reloadAllPages(false);
}

#handleBackendExecutionContextUnavailable({data: errorMessage}: ReactDevToolsBindingsBackendExecutionContextUnavailableEvent): void {
this.dispatchEventToListeners(Events.InitializationFailed, errorMessage);
}
Expand Down
4 changes: 3 additions & 1 deletion front_end/third_party/react-devtools/package/frontend.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export type Wall = {
};

export type Bridge = {
shutdown: () => void,
addListener(event: string, listener: (params: unknown) => any): void;
removeListener(event: string, listener: Function): void;
shutdown: () => void;
};
export type Store = Object;
export type BrowserTheme = 'dark' | 'light';
Expand Down

0 comments on commit 7769586

Please sign in to comment.