-
Notifications
You must be signed in to change notification settings - Fork 11
Observable mode
A-JIE edited this page Nov 1, 2017
·
1 revision
Because in the angular all the asynchronous operation will cause change detection.High-frequency operations such as the scroll event can cause significant performance losses.
So in some high-precision scenes, we can use rxjs Observable to solve. About angular asynchronous, change detection checks and zone.js. You can view it zone.js and change detection
You can switch to the Observable mode. of course, if your scene on the efficiency requirements are not high can not do so.
<infinitelist
[[width]='"100%"'
[height]='500'
[data]='data'
[itemSize]='150'
[useob]='true'
(update)='update($event)'>
<div class="li-con" *ngFor="let item of event?.items; let i=index;" [ngStyle]="event.getStyle(i)">
item{{event.start + i}}
</div>
</infinitelist>
event: ILEvent;
constructor(private cdRef: ChangeDetectorRef) { }
update($event: Subject<any>) {
$event.subscribe(x => {
this.event = x;
this.cdRef.detectChanges();
});
}