LynxAppState
Whether the app is in the foreground, as signals, so it can catch up when it comes back. import { LynxAppState } from '@blotch/angular-lynx';
Usage
Lynx pauses timers while the app is in the background, and nothing says how soon a paused timer fires once the app wakes. A screen left open overnight can go on showing yesterday until it does. Read active() to catch up the moment the app is back:
The same goes for anything else to do on the way back: reading again what isn't live, restarting an animation, or refreshing a token.
API
LynxAppState
state(): where the app is:'active','inactive'or'background'(seeLynxAppStateValue).active():truewhilestate()is'active': the app is in the foreground, taking touches. It turnsfalseas soon as the app stops taking them, before it leaves the screen.
Lynx tells the app's code nothing when it leaves the screen or comes back, so the state comes from the host app, in the appState global prop, as the accessibility settings do. Being a global prop rather than an event, it's right from the app's first line, and a change can't come before anything listens.
Your own native app can send appState the same way, with each of its global props updates.
In a spec, the testing library's setAppState() sends the app to the background and brings it back.
Types
LynxAppStateValue
'active': in the foreground, taking touches.'inactive': on screen, or on its way on or off it, but not taking touches. On iOS, Control Center or Notification Center is pulled over the app, the app switcher is open, or a call came in, and an app isinactiveas it launches, until its scene is active. On Android, another app's window has the focus, as in split screen.'background': out of sight. Lynx pauses the app's timers and animations, and the system may end it.
