Created
July 16, 2021 11:25
-
-
Save cmelchior/cc4385ba54864f8cbb54eb73f14d8ec6 to your computer and use it in GitHub Desktop.
Realm Kotlin 0.40 Release Blog Post - Threadsafe Observers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val jane = getJane() | |
CoroutineScope(Dispatchers.Main).launch { | |
// Run mapping/transform logic in the background | |
val flow: Flow<String> = jane.observe() | |
.filter { it.name.startsWith("Jane") } | |
.flowOn(Dispatchers.Unconfined) | |
// Before collecting on the UI thread | |
flow.collect { | |
println(it.name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment