From 0bd13d93addd7f33c810dd0c7cd4eb2e44c96249 Mon Sep 17 00:00:00 2001 From: Martin Fleck Date: Wed, 29 Nov 2023 14:43:08 +0100 Subject: [PATCH] Ensure form client's update listener is disposed properly Fixes https://github.com/CrossBreezeNL/crossmodel/issues/36 --- .../form-client/src/browser/form-editor-widget.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/form-client/src/browser/form-editor-widget.tsx b/packages/form-client/src/browser/form-editor-widget.tsx index 139aa553..1b92a517 100644 --- a/packages/form-client/src/browser/form-editor-widget.tsx +++ b/packages/form-client/src/browser/form-editor-widget.tsx @@ -56,11 +56,13 @@ export class FormEditorWidget extends ReactWidget implements NavigatableWidget, this.getResourceUri = this.getResourceUri.bind(this); this.loadModel(); - this.formClient.onUpdate(event => { - if (event.sourceClientId !== FORM_CLIENT_ID && event.uri === this.getResourceUri().toString()) { - this.modelUpdated(event.model); - } - }); + this.toDispose.push( + this.formClient.onUpdate(event => { + if (event.sourceClientId !== FORM_CLIENT_ID && event.uri === this.getResourceUri().toString()) { + this.modelUpdated(event.model); + } + }) + ); } protected async loadModel(): Promise {