FlowReactiveNetwork is an Android library listening network connection state and Internet connectivity with Coroutines Flow. It's a port of ReactiveNetwork library rewritten with Reactive Programming approach. Library supports both new and legacy network monitoring strategies. Min sdk version = 14.
See ReactiveNetwork docs for Usage. API is the same except for return data types:
Observable<T>
replaced byFlow<T>
Single<T>
replaced bysuspend fun():T
You can depend on the library through Gradle:
dependencies {
implementation 'ru.beryukhov:flowreactivenetwork:1.0.2'
}
// as for the library is not available in jcenter yet
allprojects {
repositories {
//...
maven {
url "https://dl.bintray.com/andreyberyukhov/FlowReactiveNetwork"
}
}
}
Tests are available in reactiveNetwork/src/test/kotlin/
directory and can be executed on JVM without any emulator or Android device from Android Studio or CLI with the following command:
./gradlew test
There are some problems with working on PreLollipop devices visible by unit-tests and tests on cancellation of Flow.