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

louiscad

09/12/2018, 2:01 PM
Hey 🤖 developers, here are 2
coroutineScope
extensions for
Lifecycle
and
LifecycleOwner
(that you can use in AppCompatActivities, Fragments, LifecycleServices...) for changes in kotlinx.coroutines 0.26.0: https://gist.github.com/LouisCAD/58d3017eedb60ce00721cb32a461980f#file-lifecyclejob-kt-L30
🎉 3
👍 2
e

elizarov

09/12/2018, 2:21 PM
Maybe PR into Android module of
kotlinx.coroutiines
?
3
l

louiscad

09/12/2018, 2:22 PM
I'd like to! It depends on Android architecture components (and AndroidX for the bleeding edge), not on the Android platform alone. Is there a module with such dependencies allowed?
e

elizarov

09/12/2018, 2:24 PM
Hm…. Shall we create a separate integration module for Android architecuter components then? (that would be also a good place to put livedata integration)
l

louiscad

09/12/2018, 2:28 PM
Mostly yes. I think there should be at least one module for lifecycles, and one for the AndroidX version (unless Google provides a better way for library developers...). For LiveData, I'm not sure every app would need the integration (I may be wrong, tell me if so), so I think it should belong to another module.
@elizarov Let me know if you need any suggestions for modules naming, or anything related to this. I'll be happy to help and then make a PR for this
t

thevery

09/12/2018, 7:58 PM
and one for the AndroidX version
oh yeah, eap+androidx = combinatorial explosion
e

elizarov

09/12/2018, 7:58 PM
It obviously has to be
kotlinx-coroutines-xxx
. Is there a short name for android architecture components?
t

thevery

09/12/2018, 7:58 PM
android-arch
👍 1
Copy code
// alternatively - just LiveData
    implementation "android.arch.lifecycle:livedata:$lifecycle_version"
https://developer.android.com/topic/libraries/architecture/adding-components#kotlin
and androidx version -
Copy code
// alternatively - just LiveData
    implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
l

louiscad

09/12/2018, 8:00 PM
I think you should have
kotlinx-coroutines-android-arch-lifecycle
and
kotlinx-coroutines-androidx-lifecycle
t

thevery

09/12/2018, 8:02 PM
There is also ReactiveStreams module (though I haven't tried it and cannot say anyhting):
Copy code
// optional - ReactiveStreams support for LiveData
    implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version" // use -ktx for Kotlin
And probably most challenging option - room+coroutines like rxjava2:
Copy code
// optional - RxJava support for Room
    implementation "android.arch.persistence.room:rxjava2:$room_version"
l

louiscad

09/12/2018, 8:04 PM
AndroidX separated everything so you can depend on just Lifecycle artifact without bringing LiveData and other things (which RxJava users often don't use, and coroutines users don't always use, if they do). kotlinx.coroutines should not remove this benefit (although that multiplies artifacts for Android, this is a good thing as not all apps need all libraries, and same goes for libraries depending on libraries)
e

elizarov

09/12/2018, 8:29 PM
Let’s start with individual integration modules then
👍 1
l

louiscad

09/13/2018, 4:48 PM
@elizarov Please let me know when you've created the modules we talked about. I'd like to start working on a PR this weekend if possible.
e

elizarov

09/13/2018, 5:48 PM
They should be created in the same PR. More details in contributions guide: https://github.com/Kotlin/kotlinx.coroutines/tree/master/integration#contributing
👍 1
l

louiscad

11/02/2018, 9:01 AM
2 Views