Update ConnectivityManagerNetworkMonitor.kt

pull/716/head
Simon Marquis 1 year ago committed by GitHub
parent de6545f5d7
commit f34ee1c01b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,11 +36,13 @@ import javax.inject.Inject
class ConnectivityManagerNetworkMonitor @Inject constructor(
@ApplicationContext private val context: Context,
) : NetworkMonitor {
override val isOnline: Flow<Boolean> {
override val isOnline: Flow<Boolean> = callbackFlow {
val connectivityManager = context.getSystemService<ConnectivityManager>()
?: return flowOf(false)
return callbackFlow {
?: run {
channel.trySend(false)
channel.close()
return@callbackFlow
}
/**
* The callback's methods are invoked on changes to *any* network, not just the active

Loading…
Cancel
Save