Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<body class="mat-typography">
<df-root></df-root>
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
<script src="runtime.52376ff5d6ec6149.js" type="module"></script><script src="polyfills.cb64ea9d35bc0a9e.js" type="module"></script><script src="main.463c52b33f808aff.js" type="module"></script></body>
<script src="runtime.52376ff5d6ec6149.js" type="module"></script><script src="polyfills.cb64ea9d35bc0a9e.js" type="module"></script><script src="main.c130ec302a7a706b.js" type="module"></script></body>
</html>
1 change: 0 additions & 1 deletion dist/main.463c52b33f808aff.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/main.c130ec302a7a706b.js

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions src/app/shared/services/df-loading-spinner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@ export class DfLoadingSpinnerService {
}

set active(value: boolean) {
// Decide on the transition from the counter itself, not from active$.value.
// Rapid toggles schedule emits via queueMicrotask; during that window
// active$.value is stale, so comparing against it loses decrements when
// several requests start and finish inside one tick (spinner stuck on).
const wasActive = this.activeCounter > 0;
if (value) {
this.activeCounter++;
} else {
this.activeCounter = Math.max(this.activeCounter - 1, 0);
}
const isActive = this.activeCounter > 0;

const shouldBeActive = this.activeCounter > 0;

// Only defer if the value is actually changing to avoid unnecessary timeouts
// This prevents ExpressionChangedAfterItHasBeenCheckedError by ensuring
// the value change happens after the current change detection cycle completes
if (this.active$.value !== shouldBeActive) {
setTimeout(() => {
this.active$.next(shouldBeActive);
}, 0);
if (wasActive !== isActive) {
// queueMicrotask runs after the current change-detection pass (so no
// ExpressionChangedAfterItHasBeenCheckedError) but before the next
// macrotask, which keeps emit ordering consistent with request ordering.
queueMicrotask(() => {
if (this.active$.value !== isActive) {
this.active$.next(isActive);
}
});
}
}
}
Loading