2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								p.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  <span class="location-badge">exported from <a href="/angular2/change_detection">angular2/change_detection</a></span>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  defined in <a href="https://github.com/angular/angular/tree/master/modules/angular2/src/core/life_cycle/life_cycle.js#L31">angular2/src/core/life_cycle/life_cycle.js (line 31)</a>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								:markdown
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Provides access to explicitly trigger change detection in an application.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 13:57:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  By default, `Zone` triggers change detection in Angular on each virtual machine (VM) turn. When testing, or in some
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  limited application use cases, a developer can also trigger change detection with the `lifecycle.tick()` method.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  Each Angular application has a single `LifeCycle` instance.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  # Example
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 13:57:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  This is a contrived example, since the bootstrap automatically runs inside of the `Zone`, which invokes
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  `lifecycle.tick()` on your behalf.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  bootstrap(MyApp).then((ref:ComponentRef) => {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var lifeCycle = ref.injector.get(LifeCycle);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var myApp = ref.instance;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ref.doSomething();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    lifecycle.tick();
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  });
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								.l-main-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2 Members
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .l-sub-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    h3 constructor
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 13:57:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        constructor(exceptionHandler:ExceptionHandler, changeDetector:ChangeDetector = null, enforceNoNewChanges:boolean = false)
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    :markdown
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .l-sub-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    h3 registerWith
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 13:57:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        registerWith(zone:VmTurnZone, changeDetector:ChangeDetector = null)
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    :markdown
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .l-sub-section
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    h3 tick
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    pre.prettyprint
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      code.
							 
						 
					
						
							
								
									
										
										
										
											2015-04-20 13:57:43 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        tick()
							 
						 
					
						
							
								
									
										
										
										
											2015-04-19 13:53:18 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    :markdown
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      Invoke this method to explicitly process change detection and its side-effects.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       In development mode, `tick()` also performs a second change detection cycle to ensure that no further
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       changes are detected. If additional changes are picked up during this second cycle, bindings in the app have
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       side-effects that cannot be resolved in a single change detection pass. In this case, Angular throws an error,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       since an Angular application can only have one change detection pass during which all change detection must
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       complete.