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

Vsevolod Tolstopyatov [JB]

04/04/2019, 1:25 PM
📣 📣 📣
kotlinx.coroutines
1.2.0-alpha-2 is here! It has one major feature preview: cold streams aka
Flow
to work with asynchronous cold streams of data. The primary goal of the feature preview is to explore its possible strengths and weaknesses, evaluate real-world use-cases and finally adapt and refine it. Try it, use it, break it! Full API reference for `Flow`: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html
🎉 34
👍 1
K 24
⏸️ 22
d

Dias

04/04/2019, 1:46 PM
how it will affect channels?
g

gildor

04/04/2019, 2:04 PM
Channels are hot and it is separate API, so looks that there are no changes in channels instead of Flow adapters
v

Vsevolod Tolstopyatov [JB]

04/04/2019, 2:06 PM
Their API will be extended (#1042, #974), hot operators like
map
will be eventually deprecated and removed (but only when
Flow
is stable). The core channel API will be left as is
👍 6
d

Dias

04/04/2019, 2:30 PM
Good to hear
g

gumil

04/04/2019, 3:33 PM
Is the usage of Flow documented somewhere?
apart from the documentation in the API docs
l

louiscad

04/04/2019, 6:28 PM
@gumil You basically asked for documentation and said that there is documentation and KDoc 😄 I think this, plus your IDE are great starting points, and that articles or talks about that new API will appear not too far in the future, I know someone planned to do so as soon as next week (but can't give guarantees though).
v

Vsevolod Tolstopyatov [JB]

04/04/2019, 10:44 PM
@gumil there are some examples in my repository with experiments: https://github.com/qwwdfsad/FlowPlayground/tree/master/src/main/kotlin/examples But it is not something I wanted to expose in the official documentation. Some samples & guides are coming in the next release
👍 3
l

louiscad

04/05/2019, 6:20 AM
@Vsevolod Tolstopyatov [JB] Is there a reason you don't use
<http://Dispatchers.IO|Dispatchers.IO>
here but use a custom single thread context instead? https://github.com/qwwdfsad/FlowPlayground/blob/master/src/main/kotlin/examples/FlowForDatabase.kt
g

gildor

04/05/2019, 7:00 AM
Do you plan to add
debounce
operator?
upd: sorry, found it in FlowPlayground
👍 1
v

Vsevolod Tolstopyatov [JB]

04/05/2019, 8:22 AM
@louiscad yes, thread name for demonstration purposes. @gildor we do, but I do not recommend using this one, it’s neither tested nor correct 🙂
g

gildor

04/05/2019, 8:24 AM
@Vsevolod Tolstopyatov [JB] Yes, I saw source code and your comments, at least it means that you are looking into this. Actually, I would like to have it because it’s very common operator for UI development which is not so easy to implement correctly, so better to have it as part of official set of operators for Flow
v

Vsevolod Tolstopyatov [JB]

04/05/2019, 8:49 AM
Good to know. We are not very experienced in UI development, so feel free to report missing operators that you are using on a regular basis
👍 1
l

littlelightcz

04/05/2019, 4:17 PM
Hmh interesting 🙂 , if this is meant to be a RxJava replacement then I personally would mainly look for operators such as debounce/sample/buffer/throttle etc. Since this kind of operator category was the only use case for RxJava I've ever had. But speaking generally I don't have a need to use RxJava features a lot/often in my code. Anyway if it could be replaced by implementation directly inside coroutines, that would be definitely nice to have -> 1 dependency less 😉 😁 + it's also nice that Flow is meant to be Reactive Streams compliant 👍
g

gildor

04/06/2019, 2:48 AM
I just found that I cannot use
flow {}
with NewInference, it crashes compiler: https://youtrack.jetbrains.com/issue/KT-30853
👍 1
3 Views