Skip to content

Instantly share code, notes, and snippets.

@Leviaran
Created February 3, 2021 06:49
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 Leviaran/795f6a70683927552dec59d961441068 to your computer and use it in GitHub Desktop.
Save Leviaran/795f6a70683927552dec59d961441068 to your computer and use it in GitHub Desktop.
suspend fun channelsExample() {
val numbersStream: Channel<Integer> = Channel(Channel.CONFLATED)
for (value in numbersStream) {
println("value updated :")
println(value)
}
numbersStream.offer(1)
numbersStream.offer(2)
numbersStream.offer(3)
val lastNumber = numbersStream.poll()
println(lastNumber)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment