Skip to content

Commit 87f66ee

Browse files
committed
Add reload-to-profile for Fusebox
1 parent eb757e8 commit 87f66ee

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

front_end/panels/react_devtools/ReactDevToolsModel.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
8080
window.addEventListener('beforeunload', () => this.#bridge?.shutdown());
8181
}
8282

83+
override dispose(): void {
84+
this.#bridge?.removeListener('reloadAppForProfiling', this.#handleReloadAppForProfiling);
85+
}
86+
8387
ensureInitialized(): void {
8488
if (this.#initializeCalled) {
8589
return;
@@ -163,10 +167,21 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
163167

164168
#finishInitializationAndNotify(): void {
165169
this.#bridge = ReactDevTools.createBridge(this.#wall);
166-
this.#store = ReactDevTools.createStore(this.#bridge);
170+
this.#store = ReactDevTools.createStore(this.#bridge, {
171+
supportsReloadAndProfile: true,
172+
});
173+
this.#attachReloadToProfileListener();
167174
this.dispatchEventToListeners(Events.InitializationCompleted);
168175
}
169176

177+
#attachReloadToProfileListener(): void {
178+
this.#bridge?.addListener('reloadAppForProfiling', this.#handleReloadAppForProfiling);
179+
}
180+
181+
#handleReloadAppForProfiling(): void {
182+
SDK.ResourceTreeModel.ResourceTreeModel.reloadAllPages(false);
183+
}
184+
170185
#handleBackendExecutionContextUnavailable({data: errorMessage}: ReactDevToolsBindingsBackendExecutionContextUnavailableEvent): void {
171186
this.dispatchEventToListeners(Events.InitializationFailed, errorMessage);
172187
}

front_end/third_party/react-devtools/package/frontend.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export type Wall = {
1515
};
1616

1717
export type Bridge = {
18-
shutdown: () => void,
18+
addListener(event: string, listener: (params: unknown) => any): void;
19+
removeListener(event: string, listener: Function): void;
20+
shutdown: () => void;
1921
};
2022
export type Store = Object;
2123
export type BrowserTheme = 'dark' | 'light';

0 commit comments

Comments
 (0)