refactor(core): removed getter and changed to readonly variable (#19117)

PR Close #19117
This commit is contained in:
Yuan Gao
2017-09-08 18:06:33 -07:00
committed by Igor Minar
parent 549f2254b4
commit b14c2d1568
9 changed files with 62 additions and 77 deletions

View File

@ -37,11 +37,10 @@ import {getSymbolIterator} from '../util';
* @stable
*/
export class QueryList<T>/* implements Iterable<T> */ {
private _dirty = true;
public readonly dirty = true;
private _results: Array<T> = [];
private _emitter = new EventEmitter();
public readonly changes: Observable<any> = new EventEmitter();
get changes(): Observable<any> { return this._emitter; }
get length(): number { return this._results.length; }
get first(): T { return this._results[0]; }
get last(): T { return this._results[this.length - 1]; }
@ -98,21 +97,18 @@ export class QueryList<T>/* implements Iterable<T> */ {
reset(res: Array<T|any[]>): void {
this._results = flatten(res);
this._dirty = false;
(this as{dirty: boolean}).dirty = false;
}
notifyOnChanges(): void { this._emitter.emit(this); }
notifyOnChanges(): void { (this.changes as EventEmitter<any>).emit(this); }
/** internal */
setDirty() { this._dirty = true; }
/** internal */
get dirty() { return this._dirty; }
setDirty() { (this as{dirty: boolean}).dirty = true; }
/** internal */
destroy(): void {
this._emitter.complete();
this._emitter.unsubscribe();
(this.changes as EventEmitter<any>).complete();
(this.changes as EventEmitter<any>).unsubscribe();
}
}