Skip to content

Commit 73e41f8

Browse files
Mark AppEventEmitter as disposable
1 parent 018440f commit 73e41f8

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

extensions/ql-vscode/src/common/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface AppEvent<T> {
44
(listener: (event: T) => void): Disposable;
55
}
66

7-
export interface AppEventEmitter<T> {
7+
export interface AppEventEmitter<T> extends Disposable {
88
event: AppEvent<T>;
99
fire(data: T): void;
1010
}

extensions/ql-vscode/src/databases/config/db-config-store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export class DbConfigStore extends DisposableObject {
6161
this.configErrors = [];
6262
this.configWatcher = undefined;
6363
this.configValidator = new DbConfigValidator(app.extensionPath);
64-
this.onDidChangeConfigEventEmitter = app.createEventEmitter<void>();
64+
this.onDidChangeConfigEventEmitter = this.push(
65+
app.createEventEmitter<void>(),
66+
);
6567
this.onDidChangeConfig = this.onDidChangeConfigEventEmitter.event;
6668
}
6769

extensions/ql-vscode/src/databases/db-manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { App } from "../common/app";
22
import { AppEvent, AppEventEmitter } from "../common/events";
33
import { ValueResult } from "../common/value-result";
4+
import { DisposableObject } from "../pure/disposable-object";
45
import { DbConfigStore } from "./config/db-config-store";
56
import {
67
DbItem,
@@ -23,7 +24,7 @@ import {
2324
import { createRemoteTree } from "./db-tree-creator";
2425
import { DbConfigValidationError } from "./db-validation-errors";
2526

26-
export class DbManager {
27+
export class DbManager extends DisposableObject {
2728
public readonly onDbItemsChanged: AppEvent<void>;
2829
public static readonly DB_EXPANDED_STATE_KEY = "db_expanded";
2930
private readonly onDbItemsChangesEventEmitter: AppEventEmitter<void>;
@@ -32,7 +33,11 @@ export class DbManager {
3233
private readonly app: App,
3334
private readonly dbConfigStore: DbConfigStore,
3435
) {
35-
this.onDbItemsChangesEventEmitter = app.createEventEmitter<void>();
36+
super();
37+
38+
this.onDbItemsChangesEventEmitter = this.push(
39+
app.createEventEmitter<void>(),
40+
);
3641
this.onDbItemsChanged = this.onDbItemsChangesEventEmitter.event;
3742

3843
this.dbConfigStore.onDidChangeConfig(() => {

extensions/ql-vscode/test/__mocks__/appMock.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ export class MockAppEventEmitter<T> implements AppEventEmitter<T> {
6363
public fire(): void {
6464
// no-op
6565
}
66+
67+
public dispose() {
68+
// no-op
69+
}
6670
}

0 commit comments

Comments
 (0)