From 009626288bddc0edcda3471bae114784b0ab7f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Wed, 4 Dec 2024 14:55:37 +0100 Subject: [PATCH] dispose event (#235267) related to #214234 --- src/vs/platform/update/common/updateIpc.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vs/platform/update/common/updateIpc.ts b/src/vs/platform/update/common/updateIpc.ts index 1c9490312fef1..d304630391859 100644 --- a/src/vs/platform/update/common/updateIpc.ts +++ b/src/vs/platform/update/common/updateIpc.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Emitter, Event } from '../../../base/common/event.js'; +import { DisposableStore } from '../../../base/common/lifecycle.js'; import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js'; import { IUpdateService, State } from './update.js'; @@ -37,6 +38,7 @@ export class UpdateChannel implements IServerChannel { export class UpdateChannelClient implements IUpdateService { declare readonly _serviceBrand: undefined; + private readonly disposables = new DisposableStore(); private readonly _onStateChange = new Emitter(); readonly onStateChange: Event = this._onStateChange.event; @@ -49,7 +51,7 @@ export class UpdateChannelClient implements IUpdateService { } constructor(private readonly channel: IChannel) { - this.channel.listen('onStateChange')(state => this.state = state); + this.disposables.add(this.channel.listen('onStateChange')(state => this.state = state)); this.channel.call('_getInitialState').then(state => this.state = state); } @@ -76,4 +78,8 @@ export class UpdateChannelClient implements IUpdateService { _applySpecificUpdate(packagePath: string): Promise { return this.channel.call('_applySpecificUpdate', packagePath); } + + dispose(): void { + this.disposables.dispose(); + } }