pwittchen / ReactiveNetwork

Android library listening network connection state and Internet connectivity with RxJava Observables
http://pwittchen.github.io/ReactiveNetwork/docs/RxJava2.x/
Apache License 2.0
2.53k stars 276 forks source link

Kotlin Flow? #368

Open ychescale9 opened 5 years ago

ychescale9 commented 5 years ago

Hi @pwittchen, now that Kotlin Coroutines Flow is stable, I'm wondering if there's any interest / plans to migrate the project to kotlin and expose Flow in the APIs (or just your thoughts in general).

I'm aware that this is a RxJava project and you're also planning to support RxJava 3 so this might be out of scope for ReactiveNetwork. But there are a couple of reasons I still want to raise this issue:

A few options I have in mind:

Regardless of what you think about this I'm still extremely grateful for the work you've put into this great library.

pwittchen commented 5 years ago

Hi @ychescale9 and thanks for your extensive feedback!

It's called ReactiveNetwork and not something like RxNetwork. I don't know maybe just because the name was taken? smiley

I used this name to indicate that library is using ReactiveExtensions and ReactiveStreams. There are other libraries with Reactive name prefix, which uses RxJava. I heard about similar projects called RxNetwork, etc. As long as I as own package name com.github.pwittchen I can release artifacts to Maven Central with any name under this package. People know this project under ReactiveNetwork name, which tells what library does, so I prefer to keep it even if RxNetwork could be a better idea for a name :)

  • It's useful because it provides reactive network change events through cold streams which fits well within a reactive / push-based architecture. I see RxJava as a layer of binding APIs for RxJava users, and there should be options for Kotlin Flow users.
  • Generally I'd like to see the ecosystem move forward. I'm not here to pitch for replacing RxJava with Coroutines and I love RxJava and all its crazy operators. But Flow and Coroutines are getting tractions with first-class support from Kotlin / Jetbrains / Google (Lifecycle already supports Coroutines, Room supports Flow in latest alpha, and Paging 3.0 is being re-written in Kotlin with Coroutines and Flow).

That's good idea!

A few options I have in mind:

  • Re-write in Kotlin and Flow in separate branch (no RxJava dependency)
  • Provide extension artifact for exposing Flow type instead of Rx Obsersvable
  • Do nothing (maybe start a new repo) :)

Right now, RxJava is tightly coupled to this library and project heavily relies on it. I think, starting a new repo and keeping this project as a reference with ideas for development would be the best option. Coroutines are slightly different concept than reactive programming. Moreover, coroutines are available in Kotlin only and this project provides support both for Java and Kotlin users. When I find some time, I consider preparing project like that, because it'd be interesting to develop it, but I cannot promise any specific release dates, etc.

Regardless of what you think about this I'm still extremely grateful for the work you've put into this great library.

Great to hear that you find it useful! Thanks! :)

ychescale9 commented 5 years ago

Thanks @pwittchen that all makes sense. In that case I'd like to take a shot at porting ReactiveNetwork to Flow in a new repo. Will ping you for feedback / insight if you're cool with this 😄

pwittchen commented 5 years ago

Sure :)

phansier commented 4 years ago

@ychescale9 did you manage to do porting? Or maybe did you find any existing analogues based on Kotlin Flow?

ychescale9 commented 4 years ago

I haven’t found the time to do it yet but hoping to get to it soon. I’ll probably do a prototype here and then move it to a proper library later.

phansier commented 4 years ago

@ychescale9 @pwittchen I've made a port by myself: https://github.com/AndreySBer/FlowReactiveNetwork Please use it. Any help or issues are welcome.

pwittchen commented 4 years ago

Great! Thanks for the update.

lion4ik commented 4 years ago

Oh, guys I have also done the same port https://github.com/lion4ik/NetworkFlow

ychescale9 commented 4 years ago

@lion4ik thanks!

Since there are a couple of alternatives now (and there’ll be more to come) I think we can close the issue now😀