goldin
12/10/2018, 10:27 PMdanny
12/10/2018, 10:30 PM/**
* Returns first element.
* @throws [NoSuchElementException] if the channel is empty.
*
* The operation is _terminal_.
* This function [consumes][ReceiveChannel.consume] all elements of the original [ReceiveChannel].
*
* **Note: This API will become obsolete in future updates with introduction of lazy asynchronous streams.**
* See [issue #254](<https://github.com/Kotlin/kotlinx.coroutines/issues/254>).
*/
first
calls consume
zak.taccardi
12/10/2018, 10:34 PM.first()
will dogoldin
12/10/2018, 10:40 PMconsumeEach
work, first
doesn’t work. I don’t understandconsumeEach
work, first
doesn’t work.danny
12/10/2018, 10:50 PMconsume
, so they cancel the channel - consumeEach
iterates over the channel, so won't return until the channel is closed/cancelledzak.taccardi
12/10/2018, 10:51 PMfor( item in channel)
to avoid closing the channel on unsubscriptiongoldin
12/10/2018, 11:22 PMfor( item in channel)
this, it will be at least strange to do a search from a single element.uli
12/11/2018, 5:38 AMgoldin
12/11/2018, 7:02 AMreceive
not get result when channel out of capacity. my capacity equal 1.Daniel Tam
12/11/2018, 1:27 PMgoldin
12/11/2018, 1:48 PMuli
12/11/2018, 6:45 PMzak.taccardi
12/11/2018, 6:45 PMuli
12/11/2018, 6:46 PM