Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pencelab/661a2757765d65ba81266dd903afd0c0 to your computer and use it in GitHub Desktop.
Save pencelab/661a2757765d65ba81266dd903afd0c0 to your computer and use it in GitHub Desktop.
val myFlow = MutableStateFlow("Initial Value")
...
val job = launch(Dispatchers.Default) {
myFlow.collect {
log("Collected => $it")
}
}
...
launch {
listOf(1, 2, 3, 3, 3, 4, 5, 6).forEach {
log("Updating => $it")
myFlow.value = "$it"
delay(300)
}
delay(1500)
job.cancel()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment