feat(LifeCycle): change LifeCycle to be able register it with a zone

This commit is contained in:
vsavkin 2014-12-10 10:48:10 -08:00
parent df36ffb11d
commit 0b550f9695
1 changed files with 13 additions and 4 deletions

View File

@ -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();
}
}