LynxNetwork
Whether the phone has a connection to the internet, as a signal, so the app can say so instead of waiting on requests that can't succeed. import { LynxNetwork } from '@blotch/angular-lynx';
Usage
Lynx has no navigator.onLine, and no IndexedDB. So a library's own offline detection and offline cache (Firestore's, say) don't work there: a request made offline just fails, or waits.
Read online() to show the person why, and to load again once the connection is back:
online() says there's a route to the internet, not that a given server answers. A request can still fail while it's true, so keep handling errors.
API
LynxNetwork
online():truewhile the phone has a connection to the internet. An app that gets no answer from its host app, as in Lynx Explorer, is online.
Lynx tells the app's code nothing about the connection, so it comes from the host app. It's the online global prop, as LynxAppState's state is.
- It's a global prop, not an event. So the app reads the latest answer its host sent from its first line, and a change can't come before anything listens.
- Until the source first answers, the app counts as online. On iOS, that's until the monitor's first path, just after launch. In the web preview, it's until the page exists, after the first render.
So on Android, a Wi-Fi network behind a captive portal, or with no way out, is offline.
The generated Android app declares ACCESS_NETWORK_STATE, which Android grants at install without asking. Your own native app can send online the same way, with each of its global props updates.
In a spec, the testing library's setOnline() takes the phone offline and brings it back.
