feat(LifeCycle): change LifeCycle to be able register it with a zone
This commit is contained in:
parent
df36ffb11d
commit
0b550f9695
|
@ -1,13 +1,22 @@
|
|||
import {FIELD} from 'facade/lang';
|
||||
import {ChangeDetector} from 'change_detection/change_detector';
|
||||
import {VmTurnZone} from 'core/zone/vm_turn_zone';
|
||||
|
||||
export class LifeCycle {
|
||||
_changeDetector:ChangeDetector;
|
||||
constructor() {
|
||||
this._changeDetector = null;
|
||||
|
||||
constructor(changeDetector:ChangeDetector) {
|
||||
this._changeDetector = changeDetector;
|
||||
}
|
||||
|
||||
digest() {
|
||||
_changeDetector.detectChanges();
|
||||
registerWith(zone:VmTurnZone) {
|
||||
zone.initCallbacks({
|
||||
onTurnDone: () => this.tick()
|
||||
});
|
||||
this.tick();
|
||||
}
|
||||
|
||||
tick() {
|
||||
this._changeDetector.detectChanges();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue