RxKotlin - Kotlin Extensions for RxJava

Overview

RxKotlin

Maven Central

Kotlin Extensions for RxJava

RxKotlin is a lightweight library that adds convenient extension functions to RxJava. You can use RxJava with Kotlin out-of-the-box, but Kotlin has language features (such as extension functions) that can streamline usage of RxJava even more. RxKotlin aims to conservatively collect these conveniences in one centralized library, and standardize conventions for using RxJava with Kotlin.

= 5 } .subscribeBy( // named arguments for lambda Subscribers onNext = { println(it) }, onError = { it.printStackTrace() }, onComplete = { println("Done!") } ) }">
import io.reactivex.rxjava3.kotlin.subscribeBy
import io.reactivex.rxjava3.kotlin.toObservable

fun main() {

    val list = listOf("Alpha", "Beta", "Gamma", "Delta", "Epsilon")

    list.toObservable() // extension function for Iterables
            .filter { it.length >= 5 }
            .subscribeBy(  // named arguments for lambda Subscribers
                    onNext = { println(it) },
                    onError =  { it.printStackTrace() },
                    onComplete = { println("Done!") }
            )

}

Contributing

Since Kotlin makes it easy to implement extensions for anything and everything, this project has to be conservative in what features are in scope. Intentions to create syntactic sugar can quickly regress into syntactic saccharin, and such personal preferences belong in one's internal domain rather than an OSS library.

Here are some basic guidelines to determine whether your contribution might be in scope for RxKotlin:

  • Is this intended feature already in RxJava?

    • If no, propose the operator in RxJava.
    • If yes, can Kotlin streamline the operator further?
  • Does this substantially reduce the amount of boilerplate code?

  • Does this make an existing operator easier to use?

  • Does RxJava not contain this feature due to Java language limitations, or because of a deliberate decision to not include it?

Kotlin Slack Channel

Join us on the #rx channel in Kotlin Slack!

https://kotlinlang.slack.com/messages/rx

Support for RxJava 3.x, RxJava 2.x and RxJava 1.x

Use RxKotlin 3.x versions to target RxJava 3.x.

  • The 3.x version is active.

Use RxKotlin 2.x versions to target RxJava 2.x.

  • The 2.x version of RxJava and RxKotlin is in maintenance mode and will be supported only through bugfixes. No new features or behavior changes will be accepted or applied.

Use RxKotlin 1.x versions to target RxJava 1.x.

  • The 1.x version of RxJava and RxKotlin reached end-of-life. No further development, support, maintenance, PRs or updates will happen.

The maintainers do not update the RxJava dependency version for every minor or patch RxJava release, so you should explicitly add the desired RxJava dependency version to your pom.xml or build.gradle(.kts).

Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

RxKotlin 3.x Build Status

Example for Maven:

<dependency>
    <groupId>io.reactivex.rxjava3groupId>
    <artifactId>rxkotlinartifactId>
    <version>3.x.yversion>
dependency>

Example for Gradle:

implementation("io.reactivex.rxjava3:rxkotlin:3.x.y")

RxKotlin 2.x Build Status

Example for Maven:

<dependency>
    <groupId>io.reactivex.rxjava2groupId>
    <artifactId>rxkotlinartifactId>
    <version>2.x.yversion>
dependency>

Example for Gradle:

implementation("io.reactivex.rxjava2:rxkotlin:2.x.y")

RxKotlin 1.x

Example for Maven:

<dependency>
    <groupId>io.reactivexgroupId>
    <artifactId>rxkotlinartifactId>
    <version>1.x.yversion>
dependency>

Example for Gradle:

implementation("io.reactivex:rxkotlin:1.x.y")

Building with JitPack

You can also use Gradle or Maven with JitPack to build directly off a snapshot, branch, or commit of this repository.

For example, to build off the 3.x branch, use this setup for Gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.ReactiveX:RxKotlin:3.x-SNAPSHOT'
}

Use this setup for Maven:

	<repositories>
		<repository>
		    <id>jitpack.ioid>
		    <url>https://jitpack.iourl>
		repository>
	repositories>

    <dependency>
	    <groupId>com.github.ReactiveXgroupId>
	    <artifactId>RxKotlinartifactId>
	    <version>3.x-SNAPSHOTversion>
	dependency>

Learn more about building this project with JitPack here.

Extensions

Target Type Method Return Type Description
BooleanArray toObservable() Observable Turns a Boolean array into an Observable
ByteArray toObservable() Observable Turns a Byte array into an Observable
ShortArray toObservable() Observable Turns a Short array into an Observable
IntArray toObservable() Observable Turns an Int array into an Observable
LongArray toObservable() Observable Turns a Long array into an Observable
FloatArray toObservable() Observable Turns a Float array into an Observable
DoubleArray toObservable() Observable Turns a Double array into an Observable
Array toObservable() Observable Turns a T array into an Observable
IntProgression toObservable() Observable Turns an IntProgression into an Observable
Iterable toObservable() Observable Turns an Iterable into an Observable
Iterator toObservable() Observable Turns an Iterator into an Observable
Observable flatMapSequence() Observable Flat maps each T emission to a Sequence
Observable > toMap() Single > Collects Pair emissions into a Map
Observable > toMultimap() Single > Collects Pair emissions into a Map >
Observable mergeAll() Observable Merges all Observables emitted from an Observable
Observable concatAll() Observable Concatenates all Observables emitted from an Observable
Observable switchLatest() Observable Emits from the last emitted Observable
Observable<*> cast() Observable Casts all emissions to the reified type
Observable<*> ofType() Observable Filters all emissions to only the reified type
Iterable merge() Observable Merges an Iterable of Observables into a single Observable
Iterable mergeDelayError() Observable Merges an Iterable of Observables into a single Observable, but delays any error
BooleanArray toFlowable() Flowable Turns a Boolean array into an Flowable
ByteArray toFlowable() Flowable Turns a Byte array into an Flowable
ShortArray toFlowable() Flowable Turns a Short array into an Flowable
IntArray toFlowable() Flowable Turns an Int array into an Flowable
LongArray toFlowable() Flowable Turns a Long array into an Flowable
FloatArray toFlowable() Flowable Turns a Float array into an Flowable
DoubleArray toFlowable() Flowable Turns a Double array into an Flowable
Array toFlowable() Flowable Turns a T array into an Flowable
IntProgression toFlowable() Flowable Turns an IntProgression into an Flowable
Iterable toFlowable() Flowable Turns an Iterable into an Flowable
Iterator toFlowable() Flowable Turns an Iterator into an Flowable
Flowable flatMapSequence() Flowable Flat maps each T emission to a Sequence
Flowable > toMap() Single > Collects Pair emissions into a Map
Flowable > toMultimap() Single >> Collects Pair emissions into a Map >
Flowable mergeAll() Flowable Merges all Flowables emitted from an Flowable
Flowable concatAll() Flowable Concatenates all Flowables emitted from an Flowable
Flowable switchLatest() Flowable Emits from the last emitted Flowable
Flowable cast() Flowable Casts all emissions to the reified type
Flowable ofType() Flowable Filters all emissions to only the reified type
Iterable merge() Flowable Merges an Iterable of Flowables into a single Flowable
Iterable mergeDelayError() Flowable Merges an Iterable of Flowables into a single Flowable, but delays any error
Single cast() Single Casts all emissions to the reified type
Observable mergeAllSingles() Observable Merges all Singles emitted from an Observable
Flowable mergeAllSingles() Flowable Merges all Singles emitted from a Flowable
Maybe cast() Maybe Casts any emissions to the reified type
Maybe ofType() Maybe Filters any emission that is the reified type
Observable mergeAllMaybes() Observable Merges all emitted Maybes
Flowable mergeAllMaybes() Flowable Merges all emitted Maybes
Action toCompletable() Completable Turns an Action into a Completable
Callable toCompletable() Completable Turns a Callable into a Completable
Future toCompletable() Completable Turns a Future into a Completable
(() -> Any) toCompletable() Completable Turns a (() -> Any) into a Completable
Observable mergeAllCompletables() Completable> Merges all emitted Completables
Flowable mergeAllCompletables() Completable Merges all emitted Completables
Observable subscribeBy() Disposable Allows named arguments to construct an Observer
Flowable subscribeBy() Disposable Allows named arguments to construct a Subscriber
Single subscribeBy() Disposable Allows named arguments to construct a SingleObserver
Maybe subscribeBy() Disposable Allows named arguments to construct a MaybeObserver
Completable subscribeBy() Disposable Allows named arguments to construct a CompletableObserver
Observable blockingSubscribeBy() Unit Allows named arguments to construct a blocking Observer
Flowable blockingSubscribeBy() Unit Allows named arguments to construct a blocking Subscriber
Single blockingSubscribeBy() Unit Allows named arguments to construct a blocking SingleObserver
Maybe blockingSubscribeBy() Unit Allows named arguments to construct a blocking MaybeObserver
Completable blockingSubscribeBy() Unit Allows named arguments to construct a blocking CompletableObserver
Disposable addTo() Disposable Adds a Disposable to the specified CompositeDisposable
CompositeDisposable plusAssign() Disposable Operator function to add a Disposable to thisCompositeDisposable

SAM Helpers (made obsolete since Kotlin 1.4)

These methods have been made obsolete with new type inference algorithm in Kotlin 1.4. They will be removed in some future RxKotlin version.

To help cope with the SAM ambiguity issue when using RxJava with Kotlin, there are a number of helper factories and extension functions to workaround the affected operators.

Observables.zip()
Observables.combineLatest()
Observable#zipWith()
Observable#withLatestFrom()
Flowables.zip()
Flowables.combineLatest()
Flowable#zipWith()
Flowable#withLatestFrom()
Singles.zip()
Single#zipWith()
Maybes.zip()

Usage with Other Rx Libraries

RxKotlin can be used in conjunction with other Rx and Kotlin libraries, such as RxAndroid, RxBinding, and TornadoFX/RxKotlinFX. These libraries and RxKotlin are modular, and RxKotlin is merely a set of extension functions to RxJava that can be used with these other libraries. There should be no overlap or dependency issues.

Other Resources

Learning RxJava Packt Book

Chapter 12 of Learning RxJava covers RxKotlin and Kotlin idioms with RxJava.

Reactive Programming in Kotlin Packt Book

The book Reactive Programming in Kotlin mainly focuses on RxKotlin, as well as learning reactive programming with Kotlin.

Comments
  • RxJava 2.0 Planning?

    RxJava 2.0 Planning?

    Is it worth discussing how this API will change with RxJava 2.0? With the release candidate out it's probably not a bad time to think about Flowables and all that.

    https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0

    Should we create a new branch for the 2.0 development?

    opened by thomasnield 26
  • Create extension functions that start addressing #103

    Create extension functions that start addressing #103

    Making this as a first step to addressing #103.

    I've only created extension functions for now, as calls like Observable.zip() are going to be hard to overload neatly (since Kotlin doesn't support static extension functions).

    opened by chris-horner 18
  • Call for a new leadership

    Call for a new leadership

    Hi everyone,

    As some of you know, I'm the original author of RxKotlin back in the days were neither Kotlin nor RxJava reached their 1.0 versions. (In fact RxKotlin wasn't independent from RxJava but part of the same repository)

    That gave me a position as the natural leader of this project, for that I'm really grateful.

    Shamefully my commitment and involvement to this project in the last months hasn't being the best due to my multiple occupations (Full time job, part time distance learning degree in Theology, other open-source projects and so on) and before hurting the community I prefer to move aside as a leader and remain only as contributor and speaker.

    There are great members of this community that surely could do a better job than me at this very moment.

    Is someone interested in this role?

    Cheers

    opened by MarioAriasC 18
  • Dealing with necessary SAM adapters with RxJava2.

    Dealing with necessary SAM adapters with RxJava2.

    With RxJava1, Kotlin's automatic SAM conversion was pretty great. It let callers use syntax like:

    Observable.zip(first, second) { a, b ->
      // Do stuff.
    }
    

    Unfortunately with RxJava2 Kotlin cannot work out which interface it's meant to convert, so the type must be specified explicitly with an adapter function like so:

    Observable.zip(first, second, BiFunction<Int, Int> { a, b ->
      // Do stuff.
    })
    

    Is this something others care about or is it just a minor annoyance? Is it in the scope of this library to provide extension functions that provide slightly nicer Kotlin syntax?

    enhancement 
    opened by chris-horner 13
  • RxJavaMath extensions

    RxJavaMath extensions

    Hi,

    I really dislike the RxJavaMath library because it requires me to wrap my existing observables. With Kotlin we can easily do this with extension methods.

    With your permission, would love to add it to the library. This will entail a new RxJavaMath dependency though.

    What do you think?

    opened by maxandron 13
  • Proposing Observable.subscribeWith { ... }

    Proposing Observable.subscribeWith { ... }

    I find the current subscriber syntax cumbersome. Here's an example:

    myObservable.subscribe(subscriber<String>()
        .onNext { println(it) }
        .onError { it.printStackTrace() }
    )
    

    The problem I have is with subscriber<String>(). Because it creates a subscriber that is later modified with .onNext and .onError, the Kotlin compiler cannot infer it's type.
    For subscriber<String>, this is not such an issue, but for subscriber<Map<String, User.Status>> this can quickly become cumbersome.

    Beside, we could better use Kotlin's amazing type inference system and use a more "Kotlin-esque" way.

    This PR introduces a new way of subscribing to an observable with this proposed API:

    myObservable.subscribeWith {
        onNext { println(it) }
        onError { it.printStackTrace() }
    }
    

    The API is using Kotlin's type-safe builder pattern.

    Let me know what you think ;)

    opened by SalomonBrys 11
  • Make cast and ofType operate on wildcard types rather than Any

    Make cast and ofType operate on wildcard types rather than Any

    Maybe.ofType, Maybe.cast and Single.cast are declared as extensions on Maybe<Any>/Single<Any> rather than on Maybe<*>/Single<*> which prevents them from being used in some cases.

    This PR fixes this and will align them with how the Observable and Flowable extensions are implemented.

    This would be a binary compatible change and all existing consumers wouldn't need to change anything.

    opened by ansman 10
  • Do these methods really belong in RxKotlin?

    Do these methods really belong in RxKotlin?

    Hi,

    Just wondering about the reasoning behind adding functions such as deferredObservable, observable or emptyObservable. They do not add anything kotlin specific.

    They might help with readability, but do they really belong in RxKotlin?

    Or am I missing something?

    Thanks

    opened by maxandron 8
  • Support LambdaConsumerIntrospection in subscribeBy.

    Support LambdaConsumerIntrospection in subscribeBy.

    ReactiveX/RxJava#5590 added the LambdaConsumerIntrospection interface to its Disposable implementations. That interface is implemented by checking that the onError consumer is exactly the internal ON_ERROR_MISSING object. Since the onErrorStub that subscribeBy uses isn't that object, hasCustomOnError will always return false.

    I'm currently fixing this by calling the different overloads of subscribe instead of passing in the stubs. I think it's the simplest way to fix the problem, but it does feel a bit kludgy, so I'm open to suggestions.

    This PR also updates the RxJava dependency to 2.1.6 to give tests access to LambdaConsumerIntrospection.

    opened by ajalt 7
  • Sam Adapters for RxJava 2.x

    Sam Adapters for RxJava 2.x

    This is the SAM adapter implementation WIP for RxKotlin 2.x, initiated from the following discussions by @chris-horner:

    https://github.com/ReactiveX/RxKotlin/issues/103 https://github.com/ReactiveX/RxKotlin/pull/109

    opened by thomasnield 7
  • Inline Completable.andThen

    Inline Completable.andThen

    Completable.andThen also gets in the way of having a nice DSL-like structure for my chains.

    Something like this would help with that:

    inline fun Completable.andThen(action: () -> Completable) = andThen(action())

    opened by eygraber 7
  • `delay` extension reduces type detection (for `Observable.create` series)

    `delay` extension reduces type detection (for `Observable.create` series)

    It seems that kotlin type recognition for Observable.create extension series will fail, after adding delay functions.

    For example, consider code below:

    data class User(val id: String, val name: String, val age: Int)
    
    val exampleUser("test0001", "Samuel", 27)
    
    fun getUserById(id: String): Single<User> {
        return Single.create { single ->
             exampleUser.copy(id = id).let { single.onSuccess(it) }
        }
    }
    

    Everything works fine.

    Now, if I add .delay behind:

    fun getUserById(id: String): Single<User> {
        return Single.create { single ->
             exampleUser.copy(id = id).let { single.onSuccess(it) }
        }.delay(500, TimeUnit.MILLISECDONDS)
    }
    

    And then build it. The editor would throw build errors at Single.create line:

    at end of `Single.create`:
    Not enough information to infer type variable T
    
    at start of `single`:
    Cannot infer a type for this parameter. Please specify it explicitly.
    

    If I specify the type, the build errors will disappear:

    fun getUserById(id: String): Single<User> {
        return Single.create<User> { single ->
             exampleUser.copy(id = id).let { single.onSuccess(it) }
        }.delay(500, TimeUnit.MILLISECDONDS)
    }
    

    However, some editor/kotlin plugin might suggest to "Remove explicit type arguments" then.

    These errors seems not only happen at Single.create, but also at Observable.create. I guess the errors happen in all .create series?

    Versions

    I'm using 3.0.1 in Android Studio.

    All Rx related version:

    implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    implementation 'com.uber.rxdogtag2:rxdogtag:2.0.1'
    implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
    implementation 'androidx.room:room-rxjava3:2.4.1'
    

    The editor and plugin version:

    Android Studio Chipmunk | 2021.2.1 Patch 1
    Build #AI-212.5712.43.2112.8609683, built on May 19, 2022
    
    Kotlin Plugin:
    212-1.7.10-release-333-AS5457.46
    
    opened by samuelchou 0
  • issue with the indirect dependency component reactive-stream License

    issue with the indirect dependency component reactive-stream License

    Hi RxKotlin is dependent on Rxjava & Rxjava is dependent on reactive-stream which has CC-1.0 license that has the issue https://github.com/reactive-streams/reactive-streams-jvm/issues/536

    That makes usage of RxKotlin problematic.

    reactive-stream plan to release new version with MIT license. which RxJava should be relied upon https://github.com/ReactiveX/RxJava/issues/7418 Please consider upgrade to the new version of RxJava which uses reactive-stream which will not be under CC-1.0 license

    please check this comment https://github.com/reactive-streams/reactive-streams-jvm/issues/536#issuecomment-1124497560 for dependency relationship

    Thanks

    opened by dineshr93 0
  • Add Flowables.combineLatest() and Flowables.zip() with additional parameters (2.x)

    Add Flowables.combineLatest() and Flowables.zip() with additional parameters (2.x)

    (This is PR #242 based on RxKotlin 2.x)

    This PR adds new functions to Flowables:

    • Flowables.combineLatest variants that take bufferSize parameter
    • Flowables.zip variants that take delayError and bufferSize parameters

    The parameters have been rearranged to make use of default parameter values and lambda syntax.

    Usage example:

    Flowables.combineLatest(Flowable.just(1), Flowable.just(2), bufferSize = 4) { i1, i2 -> i1 + i2 }
    
    opened by SpaceBison 0
  • Add Flowables.combineLatest() and Flowables.zip() with additional parameters (3.x)

    Add Flowables.combineLatest() and Flowables.zip() with additional parameters (3.x)

    This PR adds new functions to Flowables:

    • Flowables.combineLatest variants that take bufferSize parameter
    • Flowables.zip variants that take delayError and bufferSize parameters

    The parameters have been rearranged to make use of default parameter values and lambda syntax.

    Usage example:

    Flowables.combineLatest(Flowable.just(1), Flowable.just(2), bufferSize = 4) { i1, i2 -> i1 + i2 }
    
    opened by SpaceBison 0
  • Added subscribeBy(DisposableContainer, [...]) extensions.

    Added subscribeBy(DisposableContainer, [...]) extensions.

    RxJava 3.1.0 was released, which contains the following change:

    • API addition: subscribe([...], DisposableContainer) for better Disposable management and reference cleanup.

    I've added the following extension methods with named arguments;

    Observable<T>.subscribeBy(DisposableContainer, onError, onComplete, onNext)
    Flowable<T>.subscribeBy(DisposableContainer, onError, onComplete, onNext)
    Single<T>.subscribeBy(DisposableContainer, onError, onSuccess)
    Maybe<T>.subscribeBy(DisposableContainer, onError, onComplete, onSuccess)
    Completable.subscribeBy(DisposableContainer, onError, onComplete)
    

    :warning: RxJava 3.1.0 requires minimum Android API 21 (Android 5.0)

    opened by mickverm 1
Releases(3.0.1)
  • 3.0.1(Sep 19, 2020)

    • Targeting RxJava 3.0.6
    • Updated Kotlin to 1.4.10
    • Deprecated SAM helper methods, which were made obsolete with new type inference algorithm in Kotlin 1.4
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Mar 21, 2020)

    Maven coordinates for this release: io.reactivex.rxjava3:rxkotlin:3.0.0

    • Targeting RxJava 3.0.0
    • Package for RxKotlin classes and functions changed to io.reactivex.rxjava3.kotlin to align it with other RxJava-based libraries (#227).
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-RC1(Feb 1, 2020)

    • Now targeting RxJava 3 (version 3.0.0-RC9)
    • Base package for RxKotlin components changed to io.reactivex.rxkotlin3 (from io.reactivex.rxkotlin)
    • RxKotlin artifact group changed to io.reactivex.rxjava3 (from io.reactivex.rxjava2)
    Source code(tar.gz)
    Source code(zip)
  • 2.4.0(Jul 28, 2019)

  • 2.4.0-beta.1(Jun 28, 2019)

  • 2.3.0(Aug 10, 2018)

    This is the first release for RxKotlin in quite some time. I apologize it took so long.

    • RxJava updated to 2.2.0
    • Kotlin updated to 1.2.60
    • Silence unused and platform warnings #179
    • Add missing @CheckReturnValue annoations #180
    • Add zero-arg flatMapIterable and concatMapIterable #185
    • Make cast and ofType operate on wildcard types rather than Any #176
    • Add Flowables.create with lambda as last parameter #188
    • Change return type of Flowable.withLatestFrom #193

    Thank you everyone for your contributions!

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Nov 27, 2017)

    This is a breaking release removing some annoyances, specifically the toSingle() and toMaybe() extension functions targeting futures, callables, and even single T items.

    These caused far more harm than good, as they often clashed with other libraries and people's own extensions. For instance, RxKotlinFX has a Dialog<T>.toMaybe() extension which emits a dialog's response. This clashed directly with the toMaybe() in RxKotlin. Rather than deprecating these extensions, they were just removed to prevent further hindrance.

    Deprecated Observable#combineLatest() and its Flowable counterpart have been removed as well, and you can use the Observables and Flowables factories instead.

    RxJava and Kotlin dependencies have been updated as well.

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jun 24, 2017)

    There are a number of changes in this release, some of which are possibly breaking. Many additions seek to expand the SAM helpers used to workaround the SAM issue.

    • zip(), combineLatest(), zipWith(), and withLatestFrom() now support emitting Pairs and Triples when no combining function is provided for 2-3 source arguments. This applies to Observable, Flowable, Single, and Maybe types.

    • Singles and Maybes have been greatly expanded to include more SAM helper operators for zip() and zipWith()

    • toMap() and toMultimap() extension operators have been added to Observable<Pair<X,Y>> and Flowable<Pair<X,Y>>, which will automatically use each Pair emission to map the key and value without any arguments.

    • Order of parameters for subscribeBy() have been moved so that onNext is the default if only one unnamed parameter is provided.

    • Kotlin 1.2 and RxJava 2.1.0 are now dependencies

    Please file any issues if you have any questions or concerns. Thanks to everyone who contributed to this release.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(May 18, 2017)

  • 2.0.2(May 3, 2017)

    This is a re-release of the features in 2.0.1 to address some build issues during deployment. combineLatest() also received extensions to work with Pair and Triple emissions.

    Thanks @stepango for putting these changes in.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(May 2, 2017)

    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.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1-RC1(Apr 24, 2017)

    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.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Mar 20, 2017)

    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:

    • RxKotlin 2.0 supports RxJava 2.x (RxKotlin 1.0 supports RxJava 1.x)
    • Observable, Flowable, Single, Maybe, and Completable types are targeted with extension functions
    • subscribeBy() supports both Observers and Subscribers
    • Disposables and Subscriptions are both supported with convenience extension functions
    • Non-null enforcement is applied to extension function factories targeting Kotlin types, since RxJava2 does not support null emissions
    • A small set of operators targeting Observable<Single>, Flowable<Single>, Observable<Maybe>, etc are implemented as extension functions.
    • Maven groupId has been changed to io.reactivex.rxjava2
    • Root package is now io.reactivex.rxkotlin

    Special thanks to @stepango for doing a lot of the work porting this over to RxJava2.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-RC3(Mar 14, 2017)

    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.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Mar 17, 2017)

    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!

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC3(Mar 14, 2017)

    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.

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-RC1(Mar 11, 2017)

    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:

    • Package domain is io.reactivex.rxkotlin
    • Extensions are applicable to Observable and Flowable
    • Extension functions targeting null emissions have been removed
    • Extension functions have been added for Single, Maybe, and Completable
    • onComplete is the completion event name instead of onCompleted
    • Extension functions targeting Subscription now target Disposable
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0-RC2(Mar 7, 2017)

  • 1.0.0-RC1(Mar 7, 2017)

    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().

    Source code(tar.gz)
    Source code(zip)
  • v0.60.0(Jun 13, 2016)

    Kotlin version upgraded to 1.0.2, RxJava upgraded to 1.1.5

    PRs merged:

    • https://github.com/ReactiveX/RxKotlin/pull/63
    • https://github.com/ReactiveX/RxKotlin/pull/62
    • https://github.com/ReactiveX/RxKotlin/pull/60
    Source code(tar.gz)
    Source code(zip)
  • v0.55.0(Mar 20, 2016)

  • v0.50(Feb 17, 2016)

  • v0.30.1(Nov 20, 2015)

    • Updated to Kotlin beta 2
    • Drop deprecated methods
    • combineLatest and zip extension functions for List<Observable<T>>
    • += for CompositeSubscription
    Source code(tar.gz)
    Source code(zip)
  • v0.24.100(Oct 23, 2015)

  • v0.23.100(Oct 23, 2015)

    • Release for Kotlin 1.0.0-beta
    • New switchOnNext() extension function
    public fun <T> Observable<Observable<T>>.switchOnNext(): Observable<T> = Observable.switchOnNext(this)
    
    Source code(tar.gz)
    Source code(zip)
  • v0.22.14(Oct 3, 2015)

  • v0.22.13(Sep 17, 2015)

  • v0.22.12(Jun 2, 2015)

  • v0.22.11(Jun 2, 2015)

    First release for Kotlin M11 with the support of the Koltin Community

    Several changes are being implemented to make RxKotlin more idiomatic

    From this version we will use this version system where 0.22 is the version code and .11 is the Kotlin Milestone. Once Koltin reach an official release we will change to 1.0 and try to keep it consistent with Kotlin

    Source code(tar.gz)
    Source code(zip)
  • v0.21.0(Oct 1, 2014)

    This is the first release after splitting from RxJava into its own top level project RxKotlin.

    This is the same code as version 0.20.4 except:

    • all deprecated methods and types are deleted
    • now published to groupId io.reactivex instead of com.netflix.rxjava
    • artifactId is now rxkotlin instead of rxjava-kotlin
    io.reactivex:rxkotlin:0.21.0
    

    The artifacts can be found on maven Central at: http://repo1.maven.org/maven2/io/reactivex/rxkotlin

    Artifacts: Maven Central

    Source code(tar.gz)
    Source code(zip)
Owner
ReactiveX
Reactive Extensions for Async Programming
ReactiveX
Kotlin-Exposed-SQL - Example of using Exposed with Kotlin for the consumption of relational SQL Databases

Kotlin Exposed SQL Sencillo ejemplo sobre el uso y abuso de Exposed ORM de Jetbr

José Luis González Sánchez 3 Jun 14, 2022
requery - modern SQL based query & persistence for Java / Kotlin / Android

A light but powerful object mapping and SQL generator for Java/Kotlin/Android with RxJava and Java 8 support. Easily map to or create databases, perfo

requery 3.1k Dec 29, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

xcesco 117 Nov 11, 2022
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Dzikoysk 23 Oct 6, 2022
Samples demonstrating the usage of Realm-Kotlin SDK

Realm-Kotlin Samples This repository contains a set of projects to help you learn about using Realm-Kotlin SDK Each sample demonstrates different use

Realm 52 Dec 31, 2022
Collection of Kotlin APIs/tools to make using Realm Mobile database easier

Compass Kotlin API and tools to make working with Realm easier Components Compass is designed to make working with Realm easier through collection of

Arunkumar 16 Oct 4, 2022
Upsert DSL extension for Exposed, Kotlin SQL framework

Exposed Upsert Upsert DSL extension for Exposed, Kotlin SQL framework. Project bases on various solutions provided by community in the official "Expos

Reposilite Playground 23 Oct 6, 2022
sql-delight example, a plugin by Square which is pure kotlin and it is useful in kmm

Sql-Delight-Example01 Developed by Mahdi Razzaghi Ghaleh first example of sql-delight What is SqlDelight? Kotlin Multiplatform is one of the most inte

rq_mehdi 0 Jan 24, 2022
RecordMe - Record your voice application with kotlin

RecordMe A simple voice recording app. Made Using : Kotlin, Navigation Component

Steve Waweru 2 Apr 28, 2022
Starter code for Android Kotlin Fundamentals Codelab 6.1 Room

TrackMySleepQuality - Starter Code Starter code for Android Kotlin Fundamentals Codelab 6.1 Room Introduction TrackMySleepQuality is an app for record

YamanAswal 0 Jan 15, 2022
BookSearchApp - Book Search App With Kotlin

BookSearchApp IT Book Search App Search IT books with keyword and view informati

null 1 Feb 7, 2022
Memory objects for Kotlin/JVM and Java

Memoria Why should an object care about where to store their bytes? Examples Basics RAM can used as a memory storage: val ram: BytesMemory = RamMemory

null 6 Jul 29, 2022
JAKO: Just Another Kotlin Orm (PostgreSQL)

JAKO: Just Another Kotlin Orm (PostgreSQL) JAKO is a simple, minimal, no-dependency library to build and execute postgresql statements using a fluent

Alessio 6 May 27, 2022
A MySQL connector wrapper that supports mapping to Kotlin classes.

Racoon Racoon is a wrapper for the MySQL connector. It makes communicating with the database easier by providing a bunch of functionalities: Mapping q

null 1 Jun 3, 2022
Room Database Queries with Kotlin Flow

Room Database Queries with Flow This app displays a list of bus stops and arrival times. Tapping a bus stop on the first screen will display a list of

asifj96 0 Apr 26, 2022
Code samples for the second edition of "Kotlin in Action".

Code samples for Kotlin in Action, Second Edition This project contains the code samples from book "Kotlin in Action, Second Edition" by Roman Elizaro

Kotlin 16 Dec 29, 2022
SurrealDB Kotlin implementation.

Kotlin Surreal Database API KSDB | by Necrosis SurrealDB framework for Kotlin Documentation · Report Bug · Request Feature ?? Table of Contents ?? Tab

Necrosis 5 Nov 22, 2022
RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

RxJava: Reactive Extensions for the JVM RxJava is a Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-base

ReactiveX 46.8k Jan 5, 2023
FlowExt is a Kotlin Multiplatform library, that provides many operators and extensions to Kotlin Coroutines Flow

FlowExt | Kotlinx Coroutines Flow Extensions | Kotlinx Coroutines Flow Extensions. Extensions to the Kotlin Flow library | kotlin-flow-extensions | Coroutines Flow Extensions | Kotlin Flow extensions | kotlin flow extensions | Flow extensions

Petrus Nguyễn Thái Học 151 Jan 1, 2023
Android Viper template with Kotlin, Dagger 2, Retrofit & RxJava

Android VIPER Architecture Example This repository contains a detailed sample client-server app that implements VIPER(View-Interactor-Presenter-Entity

OmiSoft 33 Nov 4, 2022