Why is global state a problem in OutSystems Reactive?
Reactive apps in OutSystems work differently from traditional web pages.
Since pages aren’t always fully reloaded, the lifecycle events (OnInitialize, OnReady, OnDestroy, etc.) don’t behave exactly the same as a normal browser reload.
When you attach something like a debounce or throttle function directly to the global window object, a few issues can creep in:
(1) Functions linger longer than intended.
The same global instance may stay in memory even after you navigate away, leading to duplicated listeners or stale data.
(2) Conflicts between multiple instances.
Navigating between screens can accidentally reuse or overwrite existing globals.
(3) Hard-to-debug lifecycle behaviors.
Since Reactive apps reuse the same runtime, global functions may still fire even when the screen they belong to no longer exists.
For example, if you create a window.myThrottle, navigating between screens won’t necessarily reset it. This causes headaches when the function is bound to UI events that should reset cleanly.