From 0b550f96957f0a7b573e5880123010671b470a12 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Wed, 10 Dec 2014 10:48:10 -0800 Subject: [PATCH] feat(LifeCycle): change LifeCycle to be able register it with a zone --- modules/core/src/life_cycle/life_cycle.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/core/src/life_cycle/life_cycle.js b/modules/core/src/life_cycle/life_cycle.js index 70bfa63112..04300797e2 100644 --- a/modules/core/src/life_cycle/life_cycle.js +++ b/modules/core/src/life_cycle/life_cycle.js @@ -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(); } } \ No newline at end of file