SharedReachability

Exposes the platform network status as networkStatus and isReachable. It listens to the platform reachability from creation until destroy is called.

This class can be used as a singleton or as a property of a class.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val isReachable: StateFlow<Boolean>

Returns state flow with network reachability state. True if network available.

Link copied to clipboard

Returns state flow with network status.

Functions

Link copied to clipboard
fun destroy()

Stops listening to the platform reachability. After this call networkStatus and isReachable keep their last values and are no longer updated. Call it from the code that created the instance, once no component uses it anymore. Calling it more than once has no effect.