Skip to content

Commit fd20277

Browse files
committed
seems to work again
1 parent c234661 commit fd20277

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/cdk/table/coalesced-style-scheduler.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import {Injectable, NgZone, OnDestroy} from '@angular/core';
10-
import {Subject} from 'rxjs';
10+
import {from, Subject} from 'rxjs';
1111
import {take, takeUntil} from 'rxjs/operators';
1212

1313
/**
@@ -62,19 +62,31 @@ export class _CoalescedStyleScheduler implements OnDestroy {
6262

6363
this._currentSchedule = new _Schedule();
6464

65-
this._ngZone.onStable.pipe(
66-
take(1),
65+
this._getScheduleObservable().pipe(
6766
takeUntil(this._destroyed),
6867
).subscribe(() => {
69-
const schedule = this._currentSchedule!;
70-
this._currentSchedule = null;
68+
while (this._currentSchedule!.tasks.length || this._currentSchedule!.endTasks.length) {
69+
const schedule = this._currentSchedule!;
70+
this._currentSchedule = new _Schedule();
7171

72-
for (const task of schedule.tasks) {
73-
task();
74-
}
75-
for (const task of schedule.endTasks) {
76-
task();
72+
for (const task of schedule.tasks) {
73+
task();
74+
}
75+
76+
for (const task of schedule.endTasks) {
77+
task();
78+
}
7779
}
80+
81+
this._currentSchedule = null;
7882
});
7983
}
84+
85+
private _getScheduleObservable() {
86+
// Use onStable when in the context of an ongoing change detection cycle so that we
87+
// do not accidentally trigger additional cycles.
88+
return this._ngZone.isStable ?
89+
from(Promise.resolve(undefined)) :
90+
this._ngZone.onStable.pipe(take(1));
91+
}
8092
}

0 commit comments

Comments
 (0)