Create new event with emitter object to simplify code
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { IOptionsService } from 'common/services/Services';
|
||||
import { IEvent, EventEmitter } from 'common/EventEmitter';
|
||||
import { IEvent, EventEmitter, initEvent } from 'common/EventEmitter';
|
||||
import { ICharSizeService } from 'browser/services/Services';
|
||||
|
||||
export class CharSizeService implements ICharSizeService {
|
||||
@@ -16,8 +16,7 @@ export class CharSizeService implements ICharSizeService {
|
||||
|
||||
public get hasValidSize(): boolean { return this.width > 0 && this.height > 0; }
|
||||
|
||||
private readonly _onCharSizeChange = new EventEmitter<void>();
|
||||
public readonly onCharSizeChange = this._onCharSizeChange.event;
|
||||
public readonly onCharSizeChange = initEvent<void>();
|
||||
|
||||
constructor(
|
||||
document: Document,
|
||||
@@ -32,7 +31,7 @@ export class CharSizeService implements ICharSizeService {
|
||||
if (result.width !== this.width || result.height !== this.height) {
|
||||
this.width = result.width;
|
||||
this.height = result.height;
|
||||
this._onCharSizeChange.fire();
|
||||
this.onCharSizeChange.fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user