For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/angular-lynx/device/network.md.

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:

src/app/orders.ts
import { Component, effect, inject, untracked } from '@angular/core';
import { LYNX_ELEMENTS, LynxNetwork } from '@blotch/angular-lynx';

@Component({
  selector: 'app-orders',
  imports: [LYNX_ELEMENTS],
  template: `
    @if (network.online()) {
      <!-- the orders -->
    } @else {
      <text>An internet connection is required</text>
    }
  `,
})
export class Orders {
  readonly network = inject(LynxNetwork);

  constructor() {
    // Loaded again each time the phone comes back online.
    effect(() => {
      if (this.network.online()) untracked(() => this.#load());
    });
  }

  #load(): void {
    // fetch the orders
  }
}

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

@Injectable({ providedIn: 'root' })
class LynxNetwork {
  readonly online: Signal<boolean>;
}
  • online(): true while 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.
Where the app runsWhere it comes from
Apps from ng build --platform, iOSNWPathMonitor: online while the path is satisfied. The app starts online until the monitor first answers, just after launch
Apps from ng build --platform, AndroidThe default network: online while it has the internet capability and Android has validated it. No permission prompt
Web previewThe browser's navigator.onLine, with its online and offline events
Lynx ExplorerNone: the app is always online

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.