Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface AppEvent<T> {
(listener: (event: T) => void): Disposable;
}

export interface AppEventEmitter<T> {
export interface AppEventEmitter<T> extends Disposable {
event: AppEvent<T>;
fire(data: T): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export class DbConfigStore extends DisposableObject {
this.configErrors = [];
this.configWatcher = undefined;
this.configValidator = new DbConfigValidator(app.extensionPath);
this.onDidChangeConfigEventEmitter = app.createEventEmitter<void>();
this.onDidChangeConfigEventEmitter = this.push(
app.createEventEmitter<void>(),
);
this.onDidChangeConfig = this.onDidChangeConfigEventEmitter.event;
}

Expand Down
9 changes: 7 additions & 2 deletions extensions/ql-vscode/src/databases/db-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { App } from "../common/app";
import { AppEvent, AppEventEmitter } from "../common/events";
import { ValueResult } from "../common/value-result";
import { DisposableObject } from "../pure/disposable-object";
import { DbConfigStore } from "./config/db-config-store";
import {
DbItem,
Expand All @@ -23,7 +24,7 @@ import {
import { createRemoteTree } from "./db-tree-creator";
import { DbConfigValidationError } from "./db-validation-errors";

export class DbManager {
export class DbManager extends DisposableObject {
public readonly onDbItemsChanged: AppEvent<void>;
public static readonly DB_EXPANDED_STATE_KEY = "db_expanded";
private readonly onDbItemsChangesEventEmitter: AppEventEmitter<void>;
Expand All @@ -32,7 +33,11 @@ export class DbManager {
private readonly app: App,
private readonly dbConfigStore: DbConfigStore,
) {
this.onDbItemsChangesEventEmitter = app.createEventEmitter<void>();
super();

this.onDbItemsChangesEventEmitter = this.push(
app.createEventEmitter<void>(),
);
this.onDbItemsChanged = this.onDbItemsChangesEventEmitter.event;

this.dbConfigStore.onDidChangeConfig(() => {
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/databases/db-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DbModule extends DisposableObject {
super();

this.dbConfigStore = new DbConfigStore(app);
this.dbManager = new DbManager(app, this.dbConfigStore);
this.dbManager = this.push(new DbManager(app, this.dbConfigStore));
}

public static async initialize(app: App): Promise<DbModule> {
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/test/__mocks__/appMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@ export class MockAppEventEmitter<T> implements AppEventEmitter<T> {
public fire(): void {
// no-op
}

public dispose() {
// no-op
}
}