Use readonly over getter for exposing events

Fixes #4164
This commit is contained in:
Daniel Imms
2022-10-01 07:52:26 -07:00
parent 2659de2291
commit cf9949840b
24 changed files with 78 additions and 81 deletions
+2 -2
View File
@@ -23,9 +23,9 @@ export class BufferService extends Disposable implements IBufferService {
public isUserScrolling: boolean = false;
private _onResize = new EventEmitter<{ cols: number, rows: number }>();
public get onResize(): IEvent<{ cols: number, rows: number }> { return this._onResize.event; }
public readonly onResize = this._onResize.event;
private _onScroll = new EventEmitter<number>();
public get onScroll(): IEvent<number> { return this._onScroll.event; }
public readonly onScroll = this._onScroll.event;
public get buffer(): IBuffer { return this.buffers.active; }
+3 -8
View File
@@ -170,9 +170,11 @@ export class CoreMouseService implements ICoreMouseService {
private _encodings: { [name: string]: CoreMouseEncoding } = {};
private _activeProtocol: string = '';
private _activeEncoding: string = '';
private _onProtocolChange = new EventEmitter<CoreMouseEventType>();
private _lastEvent: ICoreMouseEvent | null = null;
private _onProtocolChange = new EventEmitter<CoreMouseEventType>();
public readonly onProtocolChange = this._onProtocolChange.event;
constructor(
@IBufferService private readonly _bufferService: IBufferService,
@ICoreService private readonly _coreService: ICoreService
@@ -225,13 +227,6 @@ export class CoreMouseService implements ICoreMouseService {
this._lastEvent = null;
}
/**
* Event to announce changes in mouse tracking.
*/
public get onProtocolChange(): IEvent<CoreMouseEventType> {
return this._onProtocolChange.event;
}
/**
* Triggers a mouse event to be sent.
*
+3 -3
View File
@@ -35,11 +35,11 @@ export class CoreService extends Disposable implements ICoreService {
private _scrollToBottom: (() => void) | undefined;
private _onData = this.register(new EventEmitter<string>());
public get onData(): IEvent<string> { return this._onData.event; }
public readonly onData = this._onData.event;
private _onUserInput = this.register(new EventEmitter<void>());
public get onUserInput(): IEvent<void> { return this._onUserInput.event; }
public readonly onUserInput = this._onUserInput.event;
private _onBinary = this.register(new EventEmitter<string>());
public get onBinary(): IEvent<string> { return this._onBinary.event; }
public readonly onBinary = this._onBinary.event;
constructor(
// TODO: Move this into a service
+3 -3
View File
@@ -28,9 +28,9 @@ export class DecorationService extends Disposable implements IDecorationService
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
public readonly onDecorationRegistered = this._onDecorationRegistered.event;
private _onDecorationRemoved = this.register(new EventEmitter<IInternalDecoration>());
public get onDecorationRemoved(): IEvent<IInternalDecoration> { return this._onDecorationRemoved.event; }
public readonly onDecorationRemoved = this._onDecorationRemoved.event;
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
@@ -99,7 +99,7 @@ class Decoration extends Disposable implements IInternalDecoration {
public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
public readonly onRender = this.onRenderEmitter.event;
private _onDispose = this.register(new EventEmitter<void>());
private readonly _onDispose = this.register(new EventEmitter<void>());
public readonly onDispose = this._onDispose.event;
private _cachedBg: IColor | undefined | null = null;
+1 -1
View File
@@ -58,7 +58,7 @@ export class OptionsService implements IOptionsService {
public options: Required<ITerminalOptions>;
private _onOptionChange = new EventEmitter<string>();
public get onOptionChange(): IEvent<string> { return this._onOptionChange.event; }
public readonly onOptionChange = this._onOptionChange.event;
constructor(options: Partial<ITerminalOptions>) {
// set the default value of each option
+2 -1
View File
@@ -13,8 +13,9 @@ export class UnicodeService implements IUnicodeService {
private _providers: {[key: string]: IUnicodeVersionProvider} = Object.create(null);
private _active: string = '';
private _activeProvider: IUnicodeVersionProvider;
private _onChange = new EventEmitter<string>();
public get onChange(): IEvent<string> { return this._onChange.event; }
public readonly onChange = this._onChange.event;
constructor() {
const defaultProvider = new UnicodeV6();