mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
More layering and compile strictness (#8973)
* add more folders to strictire compile, add more strict compile options * update ci * wip * add more layering and fix issues * add more strictness * remove unnecessary assertion * add missing checks * fix indentation * remove jsdoc
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
|
||||
const ANGULAREVENTING_SERVICE_ID = 'angularEventingService';
|
||||
export const IAngularEventingService = createDecorator<IAngularEventingService>(ANGULAREVENTING_SERVICE_ID);
|
||||
@@ -33,9 +33,8 @@ export interface IAngularEventingService {
|
||||
/**
|
||||
* 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;
|
||||
onAngularEvent(uri: string): Event<IAngularEvent>;
|
||||
|
||||
/**
|
||||
* Send an event to the dashboard; no op if the dashboard has not started listening yet
|
||||
|
||||
@@ -3,36 +3,33 @@
|
||||
* 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';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
export class AngularEventingService implements IAngularEventingService {
|
||||
public _serviceBrand: undefined;
|
||||
private _angularMap = new Map<string, Subject<IAngularEvent>>();
|
||||
private _angularMap = new Map<string, Emitter<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);
|
||||
public onAngularEvent(uri: string): Event<IAngularEvent> {
|
||||
let emitter = this._angularMap.get(uri);
|
||||
if (!emitter) {
|
||||
emitter = new Emitter<IAngularEvent>();
|
||||
this._angularMap.set(uri, emitter);
|
||||
}
|
||||
let sub = subject.subscribe(cb);
|
||||
return sub;
|
||||
return emitter.event;
|
||||
}
|
||||
|
||||
public sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void {
|
||||
const subject = this._angularMap.get(uri);
|
||||
if (!subject) {
|
||||
const emitter = this._angularMap.get(uri);
|
||||
if (!emitter) {
|
||||
this.logService.warn('Got request to send an event to a dashboard that has not started listening');
|
||||
} else {
|
||||
subject.next({ event, payload });
|
||||
emitter.fire({ event, payload });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user