Create new event with emitter object to simplify code

This commit is contained in:
Daniel Imms
2022-10-01 08:45:40 -07:00
parent 969db2bcf9
commit ed15a8e170
33 changed files with 247 additions and 307 deletions
+3 -4
View File
@@ -4,9 +4,9 @@
*/
import { IOptionsService, ITerminalOptions, FontWeight } from 'common/services/Services';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { isMac } from 'common/Platform';
import { CursorStyle } from 'common/Types';
import { initEvent } from 'common/EventEmitter';
export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
cols: 80,
@@ -57,8 +57,7 @@ export class OptionsService implements IOptionsService {
public readonly rawOptions: Required<ITerminalOptions>;
public options: Required<ITerminalOptions>;
private readonly _onOptionChange = new EventEmitter<string>();
public readonly onOptionChange = this._onOptionChange.event;
public readonly onOptionChange = initEvent<string>();
constructor(options: Partial<ITerminalOptions>) {
// set the default value of each option
@@ -97,7 +96,7 @@ export class OptionsService implements IOptionsService {
// Don't fire an option change event if they didn't change
if (this.rawOptions[propName] !== value) {
this.rawOptions[propName] = value;
this._onOptionChange.fire(propName);
this.onOptionChange.fire(propName);
}
};