API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classConnectivity

@codexo/exojs / core / stable

Whether the application should reach the network at all, right now. Two separate questions, deliberately never equated: - state - what the environment appears to provide; - mode - what the application allows. The state is a hint. `navigator.onLine === true` means the host has a network interface, not that a given origin answers; a captive portal, a dead DNS server and a firewalled origin all report as online. Nothing here promises reachability, and code that needs certainty has to try. Connectivity is not cache-specific. It is an ordinary runtime service: UI subscribes to it for an offline banner, and the cache uses it through a CachePolicyResolver rather than reaching into it.

3
props
2
methods
2
events
Import
import { Connectivity } from '@codexo/exojs'

Whether the application should reach the network at all, right now.

Two separate questions, deliberately never equated:

- state - what the environment appears to provide; - mode - what the application allows.

The state is a hint. `navigator.onLine === true` means the host has a network interface, not that a given origin answers; a captive portal, a dead DNS server and a firewalled origin all report as online. Nothing here promises reachability, and code that needs certainty has to try.

Connectivity is not cache-specific. It is an ordinary runtime service: UI subscribes to it for an offline banner, and the cache uses it through a CachePolicyResolver rather than reaching into it.

Constructors1
source is normally the application's PlatformAdapter, which satisfies NetworkHintSource. Omit it to build one over the browser's own signals - which is what lets a Connectivity exist BEFORE an application does, so the same instance can be handed to a ConnectivityPolicyResolver and to ApplicationOptions.connectivity.
Methods2
destroy(): void
Stops listening to the host and clears the signals. A hint source handed in belongs to whoever built it - normally the application's platform adapter, which outlives this - and is left alone; one this instance built for itself is torn down here.
snapshot(): NetworkSnapshot
The facts an acquisition starting now would run under, as one immutable value. This is what reaches a CachePolicyResolver and an asset type's transport decision - never this object, so neither can subscribe to it, hold it past the acquisition, or change it.
Properties3
allowsNetwork: boolean
Whether an acquisition starting now may use the network. 'unknown' counts as permitted: the host is not saying the network is gone, and refusing on no evidence would break every environment that reports nothing.
What the application allows. Defaults to 'auto', which follows state. Changing it affects acquisitions that START afterwards. One already in flight keeps the contract it began under: a request that was allowed to reach the network is not retroactively forbidden mid-transfer.
What the environment appears to provide. A hint from the host, never a promise that any particular origin is reachable.
Events2
Source