ReactiveX / RxAndroid

RxJava bindings for Android
Apache License 2.0
19.89k stars 2.94k forks source link

Kotlin multiplaform support #611

Closed vladimirlisovskij closed 1 year ago

vladimirlisovskij commented 1 year ago

Hi all! I noticed that Reactivex has many implementations for different platforms. However, they are all separated into separate libraries. For the convenience of working in kotlin projects, I propose to combine them in a Kotlin Multiplatform project. What do you think about it? Would it be useful?

I didn't know where to ask this question, so I wrote it here (sorry for this): https://github.com/ReactiveX/RxKotlin https://github.com/ReactiveX/RxAndroid https://github.com/ReactiveX/RxJava

Thanks in advance!

hsy719007146 commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

JakeWharton commented 1 year ago

I don't believe either RxJava nor this project want to force a Kotlin stdlib dependency on their consumers. Both are fundamentally Java-based projects that work for users of both Java and Kotlin.

Beyond that, you cannot have jvm { withJava() } and android() targets within the same project with Kotlin multiplatform. Only jvm() and android() can be combined, which requires that your sources are 100% Kotlin and contain no Java. So even if we wanted to combining them would require rewriting at least this project into Kotlin, if not RxJava itself.

If you want a push-based stream primitive for use in Kotlin multiplatform contexts I would suggest using kotlinx.coroutines Flow type. Completable, Single, Maybe can all be modeled as normal suspend funs and do not need a dedicated type.