RxJava bindings for Kotlin
This release focuses on "workaround" fixes for the SAM conversion issue when using Kotlin with RxJava 2.x.
Currently, the Kotlin compiler gets confused and cannot infer when presented with multiple SAM parameter overloads. Hopefully, JetBrains will resolve this issue sooner than later. Until then, we have put together some helpers to get us by:
Non-SAM zip() and withLatestFrom() extension function operators were added to Observable, Flowable, Single, and Maybe where applicable.
Observables, Flowables, Singles, and Maybes classes were added to house Kotlin-friendly non-SAM versions of zip() and combineLatest().
This does not address all operators affected by the SAM issue, but these are commonly encountered and will serve as a good start. For instance, the subscribe() function on Single and Maybe will be addressed later as they may require a different method signature.
Thanks to @chris-horner for spearheading this idea.
This is the RC for 2.0.1 which includes workaround fixes for the SAM conversion issue when using Kotlin with RxJava 2.x.
Non-SAM zip()
and withLatestFrom()
extension function operators were added to Observable
, Flowable
, Single
, and Maybe
where applicable.
Observables
, Flowables
, Singles
, and Maybes
classes were added to house Kotlin-friendly non-SAM versions of zip()
and combineLatest()
.
This does not address all operators affected by the SAM issue, but these are commonly encountered and will serve as a good start. For instance, the subscribe()
function on Single
and Maybe
will be addressed later as they may require a different method signature.
Thanks to @chris-horner for spearheading this idea.
This is the official release of RxKotlin 2.0, backed by RxJava 2.0.7.
The notes from the RxKotlin 1.0 release apply, but there are a few additional things to call out in this release:
Observable
, Flowable
, Single
, Maybe,
and Completable
types are targeted with extension functionssubscribeBy()
supports both Observers and SubscribersObservable<Single>
, Flowable<Single>
, Observable<Maybe>
, etc are implemented as extension functions.groupId
has been changed to io.reactivex.rxjava2
io.reactivex.rxkotlin
Special thanks to @stepango for doing a lot of the work porting this over to RxJava2.
This is the official release of RxKotlin 1.0, backed by RxJava 1.2.7. The vision of RxKotlin is to standardize conventions for using RxJava with Kotlin.
This project has evolved in the past few years as everyone got their bearings on Kotlin and what standards should emerge, especially when used with RxJava. Because Kotlin introduced non-member functions like listOf()
and sequenceOf()
, there was experimentation in doing similar functions like observable { }
. Extension functions allowed many interesting possibilities as well.
These experiments revealed some interesting natures about the Kotlin language. Kotlin's conciseness and lack of boilerplate easily marginalizes the need to create libraries to save a few lines of code. Intentions to create syntactic sugar can quickly result in syntactic saccharin, and such personal preferences belong in one's internal domain rather than an OSS library. This was particularly the case with non-member functions like observable { }
. Therefore, these were the first items to be removed.
Operators that are not standard in ReactiveX were removed as well to tighten focus of the library. Useful operators that are not part of the ReactiveX standard are likely better off in RxJava-Extras or a Kotlin equivalent.
The majority of what remains in RxKotlin are Observable
factories turned into extension functions, a small and focused set of operators, a subscribeBy()
builder, and a few strategically convenient extension functions.
This library may be lightweight, but hopefully it will help establish a useful standard in using RxJava with Kotlin going forward. Special thanks to @MarioAriasC, @benjchristensen, @stepango, and @JakeWharton for all their research, experimentation, contributions, efforts, and input.
For those using RxJava 2.x, RxKotlin 2.0 will be coming shortly!
GroupID has been changed to io.reactivex.rxjava2
The only other change in 2.0.0-RC3 is withIndex()
and joinToString()
have been removed. Extension function operators that deviate from ReactiveX standard operators were deemed out of scope for this project.
These operators might go into an initiative like rxkotlin-extras.
The only change in 1.0.0-RC3 is withIndex()
and joinToString()
have been removed. Extension function operators that deviate from ReactiveX standard operators were deemed out of scope for this project.
These operators might go into an initiative like rxkotlin-extras.
This is the release candidate for RxKotlin 2.0, which is backed by RxJava 2.x.
The API highly mirrors the release candidate of RxKotlin 1.0, but of course accommodates the types and nuances of RxJava 2.0.
Here is a list of differences from the RxKotlin 1.0 version:
io.reactivex.rxkotlin
Observable
and Flowable
Single
, Maybe
, and Completable
onComplete
is the completion event name instead of onCompleted
Subscription
now target Disposable
On top of RC1 changes, RC2 changes all references of onComplete
to onCompleted
to conform to RxJava 1.x standard.
This release is also to perform a second test deployment to Maven Central.
This is the release candidate of RxKotlin 1.0, which is backed by RxJava 1.2.7 and Kotlin 1.1. Please review this library and let us know if you have any feedback before the official 1.0 release, which we are aiming to do fairly quickly. Next we will tackle RxKotlin 2.0 which will be backed by RxJava 2.x.
Some of the changes in this API from the 0.x versions:
All non-member function factories have been removed as discussed in #58.
Observable<T>#joinToString()
extension function added to reduce emissions to a concatenated String
, with an optional separator
and prefix
/postfix
.
xxxArray#.toObservable()
extension functions have been corrected to iterate arrays as Iterables and not convert them to Lists, ensuring mutations are captured for subsequent subscriptions.
The Observable<T>#lift()
and Observable<T>#fold()
extension functions have been removed.
subscribeWith()
has been rename to subscribeBy()
to prevent convention clashing with RxJava2, and has been greatly simplified in its implementation.
All Subject
functions masquerading as constructors have been removed.
Extension functions targeting List<Observable<T>>
now target Iterable<Observable<T>>
.
A handful of extension functions targeting Observable<Observable<T>>
have been ported from RxPy, including mergeAll()
, concatAll()
, and switchLatest()
.
Kotlin version upgraded to 1.0.2, RxJava upgraded to 1.1.5
PRs merged: