Move code around for more linting (#8190)

* testing

* moving around all the code

* fix strict nulls
This commit is contained in:
Anthony Dresser
2019-11-04 10:41:28 -08:00
committed by GitHub
parent 3c702c15e2
commit ade68b184d
145 changed files with 248 additions and 231 deletions

View File

@@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Subscription } from 'rxjs/Subscription';
const ANGULAREVENTING_SERVICE_ID = 'angularEventingService';
export const IAngularEventingService = createDecorator<IAngularEventingService>(ANGULAREVENTING_SERVICE_ID);
export enum AngularEventType {
NAV_DATABASE,
NAV_SERVER,
DELETE_WIDGET,
PINUNPIN_TAB,
NEW_TABS,
CLOSE_TAB,
COLLAPSE_WIDGET
}
export interface IDeleteWidgetPayload {
id: string;
}
export interface IAngularEvent {
event: AngularEventType;
payload: any;
}
export interface IAngularEventingService {
_serviceBrand: undefined;
/**
* Adds a listener for the dashboard to send events, should only be called once for each dashboard by the dashboard itself
* @param uri Uri of the dashboard
* @param cb Listening function
*/
onAngularEvent(uri: string, cb: (event: IAngularEvent) => void): Subscription;
/**
* Send an event to the dashboard; no op if the dashboard has not started listening yet
* @param uri Uri of the dashboard to send the event to
* @param event event to send
*/
sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void;
}

View File

@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
import { IAngularEventingService, IAngularEvent, AngularEventType } from 'sql/platform/angularEventing/browser/angularEventingService';
import { ILogService } from 'vs/platform/log/common/log';
export class AngularEventingService implements IAngularEventingService {
public _serviceBrand: undefined;
private _angularMap = new Map<string, Subject<IAngularEvent>>();
constructor(
@ILogService private readonly logService: ILogService
) { }
public onAngularEvent(uri: string, cb: (event: IAngularEvent) => void): Subscription {
let subject = this._angularMap.get(uri);
if (!subject) {
subject = new Subject<IAngularEvent>();
this._angularMap.set(uri, subject);
}
let sub = subject.subscribe(cb);
return sub;
}
public sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void {
const subject = this._angularMap.get(uri);
if (!subject) {
this.logService.warn('Got request to send an event to a dashboard that has not started listening');
} else {
subject.next({ event, payload });
}
}
}