ConnectivityMonitor
Tells whether the device can reach the internet.
Create one monitor per process (keep it in DI or a singleton) with the platform factory: ConnectivityMonitor(context) { ... } on Android, ConnectivityMonitor { ... } elsewhere. Monitoring runs only while something collects isConnected, status or reconnected, and stops stopTimeout after the last collector leaves.
Properties
true = internet reachable under the configured policy. Hot, conflated, replays the latest value, and never emits the same value twice in a row. Only ConnectivityStatus.Disconnected reads as false.
One event per offline → online transition (after debounce), per ReconnectedPolicy. Not replayed.
Richer state: transport, metered, constrained, disconnect reason.
Functions
Calls onChange with every ConnectivityMonitor.isConnected value on the main thread (or Dispatchers.Default where no main dispatcher exists). For Swift and for code without coroutines.
Like observe, for ConnectivityMonitor.reconnected.
Like observe, for ConnectivityMonitor.status.
A response arrived from the network (any HTTP status). Cheap, thread-safe, never blocks. Ignored while nobody collects, and on Android/iOS unless HintConfig.applyOnNativePlatforms.
A request failed with an I/O error. Cheap, thread-safe, never blocks. Ignored while nobody collects, and on Android/iOS unless HintConfig.applyOnNativePlatforms.