Someone helped me with the problem of asynchrony almost 2 months ago, it works very well (and since then I added it to the list), but I still have this code in my program, which I'm not quite sure what it does .
Source:
constructor(private ngZone: NgZone) { }
ngOnInit() {
this.getPosts()
.subscribe(x => {
this.apidata = x;
this.ngZone.onMicrotaskEmpty.first().subscribe(() => {
this.largestHeight();
});
});
}
Now it is so difficult to get documentation on this, and I have tried for the past two months. They just give a definition, but not real examples. The actual line will bethis.ngZone.onMicrotaskEmpty.first().subscribe(()
1) So, ngZone basically gets access to the zone in which you are busy, and I understand that 70%
2) onMicrotaskEmpty "Reports when there are no more microtasks in the current rotation of the virtual machine.
- a) -, VM " "?
.
- b) ,
? ,
, , ?
- c) , Angular . ,
"" ? Angular
?
- d) onMicrotaskEmpty onStable,
. ? ( , ).
3) first() , , w3school: " first() ". , . console.dir .log, , , [object Object]. , ?
4) subscribe() , . , / promises. , , , ? , - , ?
, , , , , , ...: P