I'm creating an auto-scrolling function on the screen, but it becomes very heavy because the value change check is performed in setInterval.
Auto-scrolling does not change the value of the component, so you do not need to check the change check.
Are there any setInterval functions that do not perform change checks?
You should be able to use the runOutsideAngular
method in the NgZone
class.Obtain an instance of NgZone
in the Dependency Injection of the component before using it.
Sample
export classSomeCmp{
constructor(privateZone:NgZone){}
ngOnInit(){
This.ngZone.runOutsideAngular()=>{
setInterval (()=>{})
});
}
}
https://angular.io/docs/ts/latest/api/core/index/NgZone-class.html#!#runOutsideAngular-anchor
© 2024 OneMinuteCode. All rights reserved.