:mega: :mega: :mega: `kotlinx.coroutines` 1.2.0-al...
# coroutines
v
πŸ“£ πŸ“£ πŸ“£
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
how it will affect channels?
g
Channels are hot and it is separate API, so looks that there are no changes in channels instead of Flow adapters
v
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
Good to hear
g
Is the usage of Flow documented somewhere?
apart from the documentation in the API docs
l
@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
@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
@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
Do you plan to add
debounce
operator?
upd: sorry, found it in FlowPlayground
πŸ‘ 1
v
@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
@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
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
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
I just found that I cannot use
flow {}
with NewInference, it crashes compiler: https://youtrack.jetbrains.com/issue/KT-30853
πŸ‘ 1