Architecture: Angular effect() with showOverlay causing infinite re-execut...

Documentation for Sessions

🏗️ Architecture: Angular effect() with showOverlay causing infinite re-execut...

Date: 2026-01-29
Time: 15:29:29 UTC
Session: editor2-73.26
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

Angular effect() with showOverlay causing infinite re-execution and page freeze

Task: Not specified


🎯 Decision Made

Chosen:

Track overlay state to prevent duplicate calls

Options Considered:

  1. Remove message cycling from AppLoadingService
  2. Debounce showOverlay calls
  3. Track overlay state to prevent duplicate calls
  4. Move overlay logic outside effect

💭 Reasoning

CRITICAL PATTERN FOR @libs-ux/ux-loading: When using effect() with LoadingService.showOverlay(), NEVER read signals that change frequently (like cycling messages) in the same effect that calls showOverlay(). The showOverlay() method can create setIntervals internally. If the effect re-runs frequently, multiple intervals accumulate and freeze the browser. SOLUTION: Use a separate signal (_overlayShown) to track whether the overlay is already showing, and only call showOverlay() when transitioning from not-showing to showing. Read frequently-changing signals INSIDE the if-block after checking the guard condition.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation