https://github.com/erikhuizinga/flomo
Android network connection status backed by Kotlin coroutine flows
https://github.com/erikhuizinga/flomo
Last synced: 3 months ago
JSON representation
Android network connection status backed by Kotlin coroutine flows
- Host: GitHub
- URL: https://github.com/erikhuizinga/flomo
- Owner: erikhuizinga
- License: apache-2.0
- Created: 2019-06-21T23:11:30.000Z (about 6 years ago)
- Default Branch: development
- Last Pushed: 2022-01-09T15:20:25.000Z (over 3 years ago)
- Last Synced: 2025-02-15T19:37:43.046Z (4 months ago)
- Language: Kotlin
- Size: 311 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flomo
Android network connection status backed by Kotlin coroutine flows.
In other words: non-blocking network info monitoring.---
# 1. Installation
Depending on the repository you use:
- JCenter: add the following dependency to your module's Gradle config file:
```kotlin
"io.github.erikhuizinga:flomo:0.1.0-beta"
```- JitPack: follow [these instructions](https://jitpack.io/#erikhuizinga/flomo).
# 2. Usage
## 2.1. Obtain and use a `Flow` (network connection status)
```kotlin
/* Obtain a flow */
val context: Context // Your Context
val isNetworkConnectedFlow = context.isNetworkConnectedFlow
``````kotlin
/* Collect emissions from the flow */
import kotlinx.coroutines.flow.collect // This is important// Call this within your CoroutineScope instance or another suspend fun,
// because collect is a suspend fun
isNetworkConnectedFlow.collect { isConnected -> /* Use isConnected */ }
```## 2.2. Clean up
Don't forget to cancel the coroutine context in which your flow is being collected to prevent leaking the coroutine.
Flomo and Kotlin's internals make sure all resources used in the flow are cleaned up.