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gBAAgB,eAAe,AAAC,EAAC,CAAC;IACvC;AAAA,EACF;AAAA,AACF;AAAA,AA3EA,KAAK,eAAe,AAAC,0BACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,cA6BzB,WAAS,AAAC,EAAC,EA7BqC;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,yBACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YAmCK,gBAAe,IAAkB,cAAa,IApC7E,MAAK,KAAgB,WAC4B;EAAC,CAAC,CAAC,CAAC;AADrD,KAAK,eAAe,AAAC,gDACb,EAAC,GAAE,CAAG,UAAS,AAAD,CAAG;AAAC,YA+CN,UAAS,IAAkB,cAAa,GA/CX;EAAC,CAAC,CAAC,CAAC;AA2ErD","file":"angular2/src/core/life_cycle/life_cycle.es6","sourcesContent":["import {Injectable} from 'angular2/di';\nimport {ChangeDetector} from 'angular2/change_detection';\nimport {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone';\nimport {ExceptionHandler} from 'angular2/src/core/exception_handler';\nimport {isPresent} from 'angular2/src/facade/lang';\n\n/**\n * Provides access to explicitly trigger change detection in an application.\n *\n * By default, `Zone` triggers change detection in Angular on each virtual machine (VM) turn. When testing, or in some\n * limited application use cases, a developer can also trigger change detection with the `lifecycle.tick()` method.\n *\n * Each Angular application has a single `LifeCycle` instance.\n *\n * # Example\n *\n * This is a contrived example, since the bootstrap automatically runs inside of the `Zone`, which invokes\n * `lifecycle.tick()` on your behalf.\n *\n * ```javascript\n * bootstrap(MyApp).then((ref:ComponentRef) => {\n *   var lifeCycle = ref.injector.get(LifeCycle);\n *   var myApp = ref.instance;\n *\n *   ref.doSomething();\n *   lifecycle.tick();\n * });\n * ```\n * @exportedAs angular2/change_detection\n */\n@Injectable()\nexport class LifeCycle {\n  _errorHandler;\n  _changeDetector:ChangeDetector;\n  _enforceNoNewChanges:boolean;\n\n  constructor(exceptionHandler:ExceptionHandler, changeDetector:ChangeDetector = null, enforceNoNewChanges:boolean = false) {\n    this._errorHandler = (exception, stackTrace) => {\n      exceptionHandler.call(exception, stackTrace);\n      throw exception;\n    };\n    this._changeDetector = changeDetector; // may be null when instantiated from application bootstrap\n    this._enforceNoNewChanges = enforceNoNewChanges;\n  }\n\n  /**\n   * @private\n   */\n  registerWith(zone:VmTurnZone, changeDetector:ChangeDetector = null) {\n    if (isPresent(changeDetector)) {\n      this._changeDetector=changeDetector;\n    }\n\n    zone.initCallbacks({\n      onErrorHandler: this._errorHandler,\n      onTurnDone: () => this.tick()\n    });\n  }\n\n  /**\n   *  Invoke this method to explicitly process change detection and its side-effects.\n   *\n   *  In development mode, `tick()` also performs a second change detection cycle to ensure that no further\n   *  changes are detected. If additional changes are picked up during this second cycle, bindings in the app have\n   *  side-effects that cannot be resolved in a single change detection pass. In this case, Angular throws an error,\n   *  since an Angular application can only have one change detection pass during which all change detection must\n   *  complete.\n   *\n   */\n  tick() {\n    this._changeDetector.detectChanges();\n    if (this._enforceNoNewChanges) {\n      this._changeDetector.checkNoChanges();\n    }\n  }\n}\n"]}