You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a need for less synthetic and more practical examples of Channel/Actor usage. It's an understandable (because of experimental status) impression that this topic is being avoided but maybe having a reference app from JB (or Google?) will trigger a productive discussion about in-the-field use cases.
Current status:
KotlinConf 2018. @chrisbaneshttps://github.com/chrisbanes/tivi
Awesome talk about coroutines and channels. The app is rewritten to replace Single/Maybe/Completable with suspended functions. The reactive part didn't got converted to Channels tho, as one might expect, and still uses RxJava Flowable. Reactive (Rx), no channels.
Valid reactive use case, that most of these apps are trying to dodge. For example: the same idea with cached request that todo already has, but with a small twist: you hit the cache, send it to channel, perform the request, update the cache, send the fresh data to channel. This way you can't avoid having a stream of data.
I'm adding flow label here since whatever "example reactive app" we'll have a "recommended to write code with coroutines" it will have to be using flows. Also adding up for grab, because that would be great place for external contributions and, most likely, the sampel app will have to live in its own repository. We also plan to remove existing example app from the report after converting them into tests for CI purposes.
elizarov
changed the title
Provide a reference android app that uses Channels
Provide a reference reactive android app with coroutines
Jul 17, 2019
There is a need for less synthetic and more practical examples of
Channel/Actor
usage. It's an understandable (because of experimental status) impression that this topic is being avoided but maybe having a reference app from JB (or Google?) will trigger a productive discussion about in-the-field use cases.Current status:
KotlinConf 2018. @chrisbanes https://github.com/chrisbanes/tivi
Awesome talk about coroutines and channels. The app is rewritten to replace
Single/Maybe/Completable
with suspended functions. The reactive part didn't got converted to Channels tho, as one might expect, and still uses RxJavaFlowable
. Reactive (Rx), no channels.Google Sample: todo-mvp-kotlin
https://github.com/googlesamples/android-architecture/tree/todo-mvp-kotlin/
Uses suspended functions and good ol' callbacks when it's not enough. That's even pre Rx era.
Not reactive, no channels.
Google Sample: todo-mvvm-live-kotlin
https://github.com/googlesamples/android-architecture/tree/todo-mvvm-live-kotlin/
Suspended functions and workarounds like:
in order to avoid reactiveness, therefore — not truly reactive, no channels.
A subjective idea of what kind of app would fill the gap:
Could be the same todo-mvvm-kotlin
Clean architecture with clear
data/domain/ui(presentation)
layersLiveData
in the ui layer. Android LiveData / architecture components integration #258 in particular will benefit from it. Suspended functions and channels in domain and data.Valid reactive use case, that most of these apps are trying to dodge. For example: the same idea with cached request that
todo
already has, but with a small twist:you hit the cache, send it to channel, perform the request, update the cache, send the fresh data to channel.
This way you can't avoid having a stream of data.CoroutineScope
inViewModel
. Maybe usingviewModelScope
fromviewmodel-ktx
library: https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/lifecycle/viewmodel/ktx/src/main/java/androidx/lifecycle/ViewModel.ktIdiomatic error handling
Coroutines tests
The text was updated successfully, but these errors were encountered: