Expand description
App lifecycle: foreground or background, as the single fact the gate reads.
The platform reports real visibility transitions (Android
resumed/suspended, a desktop window hidden or occluded, the web’s
visibilitychange), and a game that is not on screen must stop playing and
go quiet. Every game in the portal family carries the same pair of
functions for this, plus the same static flag behind them; this is that
pair, once.
watch is idempotent, and it reads the state the app is already in before
it subscribes, because the platform only reports changes: a game that
boots straight into the background (an Android reopen, a hidden tab) would
otherwise read as foreground until the player came back and left again.
Functions§
- backgrounded
- Whether the app is in the background: the value the gate takes for
PortalView::backgrounded. - foreground
- Whether the app is in the foreground.
- watch
- Subscribe to the app’s lifecycle. Idempotent: calling it twice installs one listener, so a game may call it at boot and anything else may call it again.