Last active
July 25, 2020 21:10
-
-
Save mreram/ba88af0a9d58673ea45ce1deef78794b to your computer and use it in GitHub Desktop.
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
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.BroadcastChannel | |
import kotlinx.coroutines.channels.consume | |
import kotlinx.coroutines.test.runBlockingTest | |
import org.junit.Test | |
class BroadcastChannelTest { | |
@ExperimentalCoroutinesApi | |
companion object { | |
val broadcastChannel = BroadcastChannel<String>(2) | |
val openSubscription = broadcastChannel.openSubscription() | |
} | |
@ExperimentalCoroutinesApi | |
@Test | |
fun `send and receive a bullshit`() { | |
runBlockingTest { | |
launch { | |
openSubscription.consume { | |
println(receive()) | |
} | |
} | |
launch { | |
delay(20000) | |
broadcastChannel.send("heyyyyy" + 1) | |
} | |
} | |
} | |
} |
Author
mreram
commented
Jul 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment