From 2bb5dd9ee0b50deea9b1f8f5b263f836877c053d Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 6 Apr 2020 18:16:53 +0000 Subject: [PATCH] =?UTF-8?q?[core]=C2=A0fix=20leaking=20DisposableCollectio?= =?UTF-8?q?n.onDispose=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anton Kosyakov --- packages/core/src/common/disposable.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/core/src/common/disposable.ts b/packages/core/src/common/disposable.ts index ad91967592c8a..a9726ea6e5cf8 100644 --- a/packages/core/src/common/disposable.ts +++ b/packages/core/src/common/disposable.ts @@ -44,6 +44,10 @@ export class DisposableCollection implements Disposable { toDispose.forEach(d => this.push(d)); } + /** + * This event is fired only once + * on first dispose of not empty collection. + */ get onDispose(): Event { return this.onDisposeEmitter.event; } @@ -51,6 +55,7 @@ export class DisposableCollection implements Disposable { protected checkDisposed(): void { if (this.disposed && !this.disposingElements) { this.onDisposeEmitter.fire(undefined); + this.onDisposeEmitter.dispose(); } }