Skip to content

Instantly share code, notes, and snippets.

@chibatching
chibatching / FlowThrottleDebounce.kt
Last active November 8, 2024 00:44
Throttle and Debounce on Flow Kotlin Coroutines
fun <T> Flow<T>.throttle(waitMillis: Int) = flow {
coroutineScope {
val context = coroutineContext
var nextMillis = 0L
var delayPost: Deferred<Unit>? = null
collect {
val current = SystemClock.uptimeMillis()
if (nextMillis < current) {
nextMillis = current + waitMillis
@stkent
stkent / android-bluetooth-low-energy-resources.md
Last active August 1, 2024 08:47
Android Bluetooth Low Energy (BLE) Resources