Skip to content

Commit 14ff107

Browse files
Refactor view state and dispose handlers to methods
Converted `#createPanelDisposeHandler` and `#createViewStateChangeHandler` from class properties assigned to arrow functions into standard class methods in `src/editorController.ts` to improve readability and memory profile.
1 parent 1e72c8b commit 14ff107

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/editorController.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,24 @@ export class DatabaseViewerProvider extends Disposable implements vsc.CustomRead
145145
/**
146146
* Create handler for webview panel disposal.
147147
*/
148-
#createPanelDisposeHandler = (webviewPanel: vsc.WebviewPanel) => () => {
149-
this.webviewBridges.delete(webviewPanel);
150-
};
148+
#createPanelDisposeHandler(webviewPanel: vsc.WebviewPanel) {
149+
return () => {
150+
this.webviewBridges.delete(webviewPanel);
151+
};
152+
}
151153

152154
/**
153155
* Create handler for webview panel view state changes.
154156
*/
155-
#createViewStateChangeHandler = (_webviewPanel: vsc.WebviewPanel, document: DatabaseDocument) => (e: vsc.WebviewPanelOnDidChangeViewStateEvent) => {
156-
// If the webview panel is active and there is a pending save, save the document
157-
document.hasActiveViewer = e.webviewPanel.active;
158-
if (e.webviewPanel.active && document.hasPendingSave) {
159-
document.triggerSave().catch(() => { });
160-
}
161-
};
157+
#createViewStateChangeHandler(_webviewPanel: vsc.WebviewPanel, document: DatabaseDocument) {
158+
return (e: vsc.WebviewPanelOnDidChangeViewStateEvent) => {
159+
// If the webview panel is active and there is a pending save, save the document
160+
document.hasActiveViewer = e.webviewPanel.active;
161+
if (e.webviewPanel.active && document.hasPendingSave) {
162+
document.triggerSave().catch(() => { });
163+
}
164+
};
165+
}
162166

163167
/**
164168
* Resolve a webview panel for the document.

0 commit comments

Comments
 (0)