Skip to content

Commit

Permalink
dispose event (microsoft#235267)
Browse files Browse the repository at this point in the history
related to microsoft#214234
  • Loading branch information
joaomoreno authored Dec 4, 2024
1 parent 89932b6 commit 0096262
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vs/platform/update/common/updateIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<State>();
readonly onStateChange: Event<State> = this._onStateChange.event;
Expand All @@ -49,7 +51,7 @@ export class UpdateChannelClient implements IUpdateService {
}

constructor(private readonly channel: IChannel) {
this.channel.listen<State>('onStateChange')(state => this.state = state);
this.disposables.add(this.channel.listen<State>('onStateChange')(state => this.state = state));
this.channel.call<State>('_getInitialState').then(state => this.state = state);
}

Expand All @@ -76,4 +78,8 @@ export class UpdateChannelClient implements IUpdateService {
_applySpecificUpdate(packagePath: string): Promise<void> {
return this.channel.call('_applySpecificUpdate', packagePath);
}

dispose(): void {
this.disposables.dispose();
}
}

0 comments on commit 0096262

Please sign in to comment.