https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

02/07/2017, 7:42 AM
kotlinx.coroutines
version
0.7-beta
is published. It includes production-quality mostly lock-free implementation of Go-style channels that enable coroutines to safely share streams of arbitrary elements or messages without actually sharing any mutable state (e.g. share data by communicating). More details here: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#channels
👍 11
d

defhlt

02/07/2017, 9:26 AM
Can’t fully believe we are going to have channels on Android soon 🙂
k

kenkyee

02/07/2017, 12:10 PM
Does this look like Rx Observables to anyone else? ☺️
d

defhlt

02/07/2017, 12:35 PM
@kenkyee of course it does, but it’s potentially more powerful and simple. For instance, you can use language’s
for
,
if
and so on with it, but you can’t with rxjava (you need
filter
,
doOnEach
and so on)
e

elizarov

02/07/2017, 1:22 PM
It is conceptually very different from Rx. You can use it to do the same stuff that you do with Rx. However, you don’t have to learn dozens of Rx operators. With just a few primitives you can do control flow and logic of arbitrary complexity.
👍 1
d

defhlt

02/07/2017, 1:46 PM
will Kotlin have alts!/select operator?
e

elizarov

02/07/2017, 2:10 PM
yes
It will be called
select
. Something like:
Copy code
select {
    chan1.receive() { elem1 -> doSmth(elem1) }
    chan2.receive() { elem2 -> doSmth(elem2) }
}
👍 1
To clarify, this is nothing to do with Kotlin as a language. It will be part of
kotlinx.coroutines
library. Kotlin as a language is powerful enough, so that all those features can be written in a library.
👍 1
5 Views