remove event emitter and use event and emitter instead (#5361)

This commit is contained in:
Anthony Dresser
2019-05-06 00:27:55 -07:00
committed by GitHub
parent 08ed9d285e
commit b9d985b663
13 changed files with 55 additions and 396 deletions

View File

@@ -7,7 +7,6 @@ import { Action, IActionItem, IActionRunner } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
import { EventEmitter } from 'sql/base/common/eventEmitter';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { EditDataEditor } from 'sql/workbench/parts/editData/browser/editDataEditor';
import * as nls from 'vs/nls';
@@ -151,7 +150,7 @@ export class ChangeMaxRowsAction extends EditDataAction {
* Action item that handles the dropdown (combobox) that lists the avaliable number of row selections
* for an edit data session
*/
export class ChangeMaxRowsActionItem extends EventEmitter implements IActionItem {
export class ChangeMaxRowsActionItem implements IActionItem {
public actionRunner: IActionRunner;
public defaultRowCount: number;
@@ -167,7 +166,6 @@ export class ChangeMaxRowsActionItem extends EventEmitter implements IActionItem
private _editor: EditDataEditor,
@IContextViewService contextViewService: IContextViewService,
@IThemeService private _themeService: IThemeService) {
super();
this._options = ['200', '1000', '10000'];
this._currentOptionsIndex = 0;
this.toDispose = [];

View File

@@ -433,7 +433,7 @@ export class ProfilerEditor extends BaseEditor {
if (this._stateListener) {
this._stateListener.dispose();
}
this._stateListener = input.state.addChangeListener(e => this._onStateChange(e));
this._stateListener = input.state.onProfilerStateChange(e => this._onStateChange(e));
this._onStateChange({
isConnected: true,
isRunning: true,

View File

@@ -123,7 +123,7 @@ export class ProfilerTableEditor extends BaseEditor implements IProfilerControll
if (this._stateListener) {
this._stateListener.dispose();
}
this._stateListener = input.state.addChangeListener(e => this._onStateChange(e));
this._stateListener = input.state.onProfilerStateChange(e => this._onStateChange(e));
input.data.onRowCountChange(() => {
this._profilerTable.updateRowCount();
this._updateRowCountStatus();

View File

@@ -3,8 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { EventEmitter } from 'sql/base/common/eventEmitter';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
export interface IProfilerStateChangedEvent {
isConnected?: boolean;
@@ -25,7 +25,6 @@ export interface INewProfilerState {
}
export class ProfilerState implements IDisposable {
private static _CHANGED_EVENT = 'changed';
private _isConnected: boolean;
private _isRunning: boolean;
@@ -33,7 +32,6 @@ export class ProfilerState implements IDisposable {
private _isStopped: boolean;
private _autoscroll: boolean;
private _isPanelCollapsed = true;
private _eventEmitter: EventEmitter;
public get isConnected(): boolean { return this._isConnected; }
public get isRunning(): boolean { return this._isRunning; }
@@ -42,16 +40,10 @@ export class ProfilerState implements IDisposable {
public get autoscroll(): boolean { return this._autoscroll; }
public get isPanelCollapsed(): boolean { return this._isPanelCollapsed; }
constructor() {
this._eventEmitter = new EventEmitter();
}
private readonly _onProfilerStateChange = new Emitter<IProfilerStateChangedEvent>();
public readonly onProfilerStateChange = this._onProfilerStateChange.event;
public dispose(): void {
this._eventEmitter.dispose();
}
public addChangeListener(listener: (e: IProfilerStateChangedEvent) => void): IDisposable {
return this._eventEmitter.addListener(ProfilerState._CHANGED_EVENT, listener);
}
public change(newState: INewProfilerState): void {
@@ -109,7 +101,7 @@ export class ProfilerState implements IDisposable {
}
if (somethingChanged) {
this._eventEmitter.emit(ProfilerState._CHANGED_EVENT, changeEvent);
this._onProfilerStateChange.fire(changeEvent);
}
}
}

View File

@@ -26,7 +26,6 @@ import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
import { attachEditableDropdownStyler, attachSelectBoxStyler } from 'sql/platform/theme/common/styler';
import { EventEmitter } from 'sql/base/common/eventEmitter';
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
/**
@@ -428,7 +427,7 @@ export class ListDatabasesAction extends QueryTaskbarAction {
* Action item that handles the dropdown (combobox) that lists the available databases.
* Based off StartDebugActionItem.
*/
export class ListDatabasesActionItem extends EventEmitter implements IActionItem {
export class ListDatabasesActionItem implements IActionItem {
public static ID = 'listDatabaseQueryActionItem';
public actionRunner: IActionRunner;
@@ -450,7 +449,6 @@ export class ListDatabasesActionItem extends EventEmitter implements IActionItem
@IContextViewService contextViewProvider: IContextViewService,
@IConfigurationService private readonly _configurationService: IConfigurationService
) {
super();
this._toDispose = [];
this._databaseListDropdown = $('.databaseListDropdown');
this._isInAccessibilityMode = this._configurationService.getValue('editor.accessibilitySupport') === 'on';