Skip to content

Instantly share code, notes, and snippets.

@RBusarow
RBusarow / BroadcastFlow.kt
Last active January 7, 2020 19:33
A hot flow which will auto-start upon its first observer, broadcast to multiple observers, auto-close when there are no observers, and restart when observed again.
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ProducerScope
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@FlowPreview
@ExperimentalCoroutinesApi
@dmarcato
dmarcato / strip_play_services.gradle
Last active December 21, 2022 10:10
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')