Giter Site home page Giter Site logo

rxkotlin's Introduction

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.

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

โš ๏ธ (16/10/2023) We are currently not accepting contributions due to lack of developers capable of handling them in a reasonable manner.

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.rxjava3</groupId>
    <artifactId>rxkotlin</artifactId>
    <version>3.x.y</version>
</dependency>

Example for Gradle:

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

RxKotlin 2.x Build Status

Example for Maven:

<dependency>
    <groupId>io.reactivex.rxjava2</groupId>
    <artifactId>rxkotlin</artifactId>
    <version>2.x.y</version>
</dependency>

Example for Gradle:

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

RxKotlin 1.x

Example for Maven:

<dependency>
    <groupId>io.reactivex</groupId>
    <artifactId>rxkotlin</artifactId>
    <version>1.x.y</version>
</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.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

    <dependency>
	    <groupId>com.github.ReactiveX</groupId>
	    <artifactId>RxKotlin</artifactId>
	    <version>3.x-SNAPSHOT</version>
	</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<T> into an Observable
Iterator toObservable() Observable Turns an Iterator<T> into an Observable
Observable flatMapSequence() Observable Flat maps each T emission to a Sequence<R>
Observable<Pair<A,B>> toMap() Single<Map<A,B>> Collects Pair<A,B> emissions into a Map<A,B>
Observable<Pair<A,B>> toMultimap() Single<Map<A, List<B>> Collects Pair<A,B> emissions into a Map<A,List<B>>
Observable<Observable> mergeAll() Observable Merges all Observables emitted from an Observable
Observable<Observable> concatAll() Observable Concatenates all Observables emitted from an Observable
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<Observable> merge() Observable Merges an Iterable of Observables into a single Observable
Iterable<Observable> 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<T> into an Flowable
Iterator toFlowable() Flowable Turns an Iterator<T> into an Flowable
Flowable flatMapSequence() Flowable Flat maps each T emission to a Sequence<R>
Flowable<Pair<A,B>> toMap() Single<Map<A,B>> Collects Pair<A,B> emissions into a Map<A,B>
Flowable<Pair<A,B>> toMultimap() Single<Map<A, List<B>>> Collects Pair<A,B> emissions into a Map<A,List<B>>
Flowable<Flowable> mergeAll() Flowable Merges all Flowables emitted from an Flowable
Flowable<Flowable> concatAll() Flowable Concatenates all Flowables emitted from an Flowable
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<Flowable> merge() Flowable Merges an Iterable of Flowables into a single Flowable
Iterable<Flowable> 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<Single> mergeAllSingles() Observable Merges all Singles emitted from an Observable
Flowable<Single> 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<Maybe> mergeAllMaybes() Observable Merges all emitted Maybes
Flowable<Maybe> 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.

rxkotlin's People

Contributors

ajalt avatar ansman avatar bemusementpark avatar benjchristensen avatar benwicks avatar bryant1410 avatar cbruegg avatar cy6ergn0m avatar dsvoronin avatar eddieringle avatar hkurokawa avatar joshfriend avatar krossovochkin avatar laimiux avatar lenguyenthanh avatar marioariasc avatar matwood avatar maxmyalkin avatar mg6maciej avatar noloman avatar pt2121 avatar rivuchk avatar salomonbrys avatar stepango avatar subhrajyotisen avatar tasugi avatar tatsuyafujisaki avatar thomasnield avatar ultimate-deej avatar vpriscan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxkotlin's Issues

Improve README doc

We should comprehensively list all the extensions available in the README. We do not need examples for everything, but we should create a comprehensive table to give visibility into the DSL without looking at source code.

Change Implementation of Disposable.addTo to use DisposableContainer

Change implementation of

fun Disposable.addTo(compositeDisposable: CompositeDisposable): Disposable

to

fun Disposable.addTo(compositeDisposable: DisposableContainer): Disposable

This would enable the use of custom DisposableContainers. The current implementation limits use to CompositeDisposeables.

For example, on Android it is possible to build a DisposableContainer that auto-disposes based on the Android lifecycle. However it is not possible to use observable.addTo(myCustomDisposeable)

Math/Statistical Extension Functions

It might be helpful to create math/statistical reducing extension functions like so...

import rx.Observable
import java.math.BigDecimal

fun Observable<Int>.sumInt() = reduce {total, next -> total + next }
fun Observable<Long>.sumLong() = reduce {total, next -> total + next }
fun Observable<BigDecimal>.sumBigDecimal() = reduce(BigDecimal.ZERO) { total, next -> total + next }

fun Observable<Int>.minInt() = reduce {min, next -> if (min > next) next else min }
fun Observable<Long>.minLong() = reduce {min, next -> if (min > next) next else min }
fun Observable<BigDecimal>.minBigDecimal() = reduce { min, next -> if (min > next) next else min }

fun Observable<Int>.maxInt() = reduce {min, next -> if (min < next) next else min }
fun Observable<Long>.maxLong() = reduce {min, next -> if (min < next) next else min }
fun Observable<BigDecimal>.maxBigDecimal() = reduce { min, next -> if (min < next) next else min }

fun Observable<Int>.averageInt() = this.publish().autoConnect(2).let {
    Observable.zip(it.sumInt(), it.count()) { sum, count -> sum / count }
}
// and so on...

Of course, it might be better to split extension functions for Int, Double, Long, Float, and BigDecimalin separate files so we can call all of themsum()instead ofsumLong()`, and usage would explicitly import the ones we want.

Thoughts?

RxKotlin Bootstrap

RxKotlin has been extracted from RxJava prior to 1.0 as per ReactiveX/RxJava#589

I have done this with a simply copy/paste/commit for now. Commit history remains in the 0.20.x branch of RxJava: https://github.com/ReactiveX/RxJava/tree/0.20.x

If anyone wishes to replace the code in this project with files that retain commit history, go ahead and make the changes.

Over the coming weeks the build and release process will be updated.

This project does not need to release immediately as 1.0. It can continue with 0.x releases until it makes sense to hit 1.0. Its lifecycle is now decoupled from RxJava.

Deprecate T.toObservable(), T.toSingle(), etc.

These extensions for a single item T create a lot of confusion, especially with Iterables. I think these should be deprecated because they are arguable syntactic saccharin.

"Alpha".toSingle() // why not just use Single.just("Alpha") ?
myList.toObservable() // which one is it invoking?

Updating snippet on main page

Hi,

I spent about 25 min trying to debug why I couldn't get rxkotlin working, only to realize that when I added rxkotlin as an external jar directly to my project, the import syntax is,

import io.reactivex.rxkotlin.toObservable

Instead of

import rx.Observable

as shown in the main page code snippet. Is the snipped out of date, or am I simply doing something wrong?

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

Rid Java 8 requirement

I have no idea why I didn't remove this when I was debugging the build problems with Kotlin 1.1. I'll remove this later so Android users are not restricted from using this.

Call the named arguments for lambda Subscribers within subscribeBy method

In using RxJava 2.x it is possible to call the override function within the subscribe method

observableFunction.subscribe(object : Observer<T> {
    override fun onNext(t: T?) {
        println("onNext")

        // Do the task in onComplete function
        onComplete()
    }

    override fun onComplete() {
        // Task after received the onComplete() call
        println("onComplete after onNext")
    }

    override fun onSubscribe(d: Disposable?) {}

    override fun onError(e: Throwable?) {}
})

In RxKotlin the subscribeBy method can name the lambda Subscribers for better readability with lesser code. Yet is it possible to call the function within the subscribeBy method?

observableFunction.subscribeBy( 
    onNext = { status ->
        println("onNext")

        // Do the task in onComplete function
        // Solution??
    },  
    onError = {},
    onComplete = {
        // Task after received the onComplete() call
        println("onComplete after onNext")
    }
)

Another useful function ?

When you want to use RX with a external lib that doesn't use RX, you need to wrap the library call with

Observable.defer { Observable.just { lib.method() }}

I think it may be useful to have a function for that. I tried to write the following, but it doesn't compile and I didn't find why.

fun <T> rxify(body: () -> T): Observable<T> = Observable.defer(Observable.just(body))

Do you think it's relevant and if yes can you help me write it correctly :P (I'm a kotlin noob) ?

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

subscribeWith using function variable

Hi, i got IllegalArgumentException

05-09 13:49:38.811 14734 14734 W System.err: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method b.d.b.k.b, parameter it
05-09 13:49:38.811 14734 14734 W System.err:    at com.myandroid.detail.h$aa$2.a(DetailPresenter.kt)
05-09 13:49:38.811 14734 14734 W System.err:    at com.myandroid.detail.h$aa$2.invoke(DetailPresenter.kt:28)
05-09 13:49:38.811 14734 14734 W System.err:    at e.e.a.a.onNext(subscribers.kt:25)
05-09 13:49:38.811 14734 14734 W System.err:    at e.g.b.onNext(SafeSubscriber.java:139)
05-09 13:49:38.811 14734 14734 W System.err:    at e.d.a.g$2$1.onNext(OnSubscribeRedo.java:249)
05-09 13:49:38.811 14734 14734 W System.err:    at e.d.a.p$a.call(OperatorObserveOn.java:215)
05-09 13:49:38.811 14734 14734 W System.err:    at e.a.b.b$b.run(LooperScheduler.java:107)
05-09 13:49:38.811 14734 14734 W System.err:    at android.os.Handler.handleCallback(Handler.java:730)
05-09 13:49:38.811 14734 14734 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 13:49:38.811 14734 14734 W System.err:    at android.os.Looper.loop(Looper.java:137)
05-09 13:49:38.811 14734 14734 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:5103)
05-09 13:49:38.811 14734 14734 W System.err:    at java.lang.reflect.Method.invokeNative(Native Method)
05-09 13:49:38.811 14734 14734 W System.err:    at java.lang.reflect.Method.invoke(Method.java:525)
05-09 13:49:38.811 14734 14734 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
05-09 13:49:38.811 14734 14734 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-09 13:49:38.818 14734 14734 W System.err:    at dalvik.system.NativeStart.main(Native Method)

when using subscribeWith(subscriber)

private val subscriber : FunctionSubscriberModifier<Unit>.() -> Unit = {
        onStart { viewReference?.get()?.showLoading() }
        onNext {  }
        onError {
            viewReference?.get()?.hideLoading()
            viewReference?.get()?.showError(it)
        }
        onCompleted { viewReference?.get()?.hideLoading() }
    }

But not when using it like below:

subscribeWith {
        onStart { viewReference?.get()?.showLoading() }
        onNext {  }
        onError {
            viewReference?.get()?.hideLoading()
            viewReference?.get()?.showError(it)
        }
        onCompleted { viewReference?.get()?.hideLoading() }
}

How to avoid the exception when using subscribeWith with variable to function?
I'm using subscribeWith to retrofit Observable.

Major Release

The Kotlin community has been working in a proper release for RxKotlin

@benjchristensen Which steps we need to take to create release?

Build issues with 2.x

I'm getting the strangest issue with the 2.x branch. Another branch with identical contents builds fine, but the moment I have it on the 2.x branch I get a Gradle build error as shown below.

image

It is complaining about this line in the build.gradle file

apply plugin: 'nebula.rxjava-project'

Add completable method wrapping Completable.create

Why no completable method that is comparable to single or observable which takes a closure with a subscriber as its sole argument? To wrap an async Java API based on listener, I needed it and workarounded by invoking Completable.create directly.

Kotlin M9

Update this project to support M9 release of kotlin.

BehaviorSubject vs BehaviourSubject inconsistency

See these lines

public fun <T> BehaviourSubject() : BehaviorSubject<T> = BehaviorSubject.create()
public fun <T> BehaviourSubject(default : T) : BehaviorSubject<T> = BehaviorSubject.create(default)

For clarity

BehaviourSubject
BehaviorSubject

DSL for Multiple Lambda Operators?

I recently discovered thesubscribeWith() operator in this project and I find it pretty elegant.

val source = Observable.just("Alpha","Beta","Gamma")

source.subscribeWith {
     onNext { println("NEXT $it") }
     onCompleted { println("DONE!") }
}

I wonder if we can do something similar with Observable operators that accept multiple lambda arguments. For example, instead of this...

fun <T> Observable<T>.toImmutableList() =
        collect({ ImmutableList.builder<T>() },{ b, t -> b.add(t) })
        .map { it.build() }

You can explicitly specify each lambda argument

fun <T> Observable<T>.toImmutableList() =
    collect { 
            stateFactory { ImmutableList.builder<T>() } 
            collector { b, t -> b.add(t) } 
    }.map { it.build() }

Do any of you think this is worthwhile?

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?

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

concat() extension method

I wondered why there is no concat() extension method. For example there's already an extension method for switchOnNext()

filterNotNull() doesn't chain unsubscribe()

val subscription = Observable.timer(2, TimeUnit.SECONDS)
    .filterNotNull()
    .subscribe { fail() }
subscription.unsubscribe()

unsubscribe() should stop Observable chain.
But, above code reaches to fail().

If replace filterNotNull() to filter { it != null }, above code not reaches to fail().

Subscriber(Subscriber) may fix this issue.

Needs rebuild for 1.0?

Hiya, could you rebuild for 1.0 and maybe sync the version number with RxJava? It briefly confused me that the version number wasn't listed anywhere, and yet wasn't the same as RxJava.

Library has an unsupported format

I have added this library version 0.21.0 to my project. Now when I open any class I have attached message on top of the editor
screenshot 2015-03-27 11 13 27

I am using Android Studio 1.1.0 and Kotlin plugin 0.11.91

Could not find 0.50 release

I could not find 0.50 in bintray or maven repo.
Could you please update the repo with this release?
Thank you.

Observable construction syntax

What do you think about this?

fun main(args: Array<String>) {
    val pets = observable<String> {
        it onNext "world"
        it onNext "cat"
        it onNext "dog"
        it.onCompleted()
    }

    pets.map { "Hello, $it!" }
        .subscribe { println(it) }
}

fun <T> observable(f: (Subscriber<in T>) -> Unit)
        = Observable.create(f)

RxKotlin - Pure implementation for JVM, Native, JS

Lately we have seen Kotlin/Native tech preview as well as Kotlin JavaScript compiler. As I understand it one of main advantages of developing in these techs would be to be able to have modules written in pure Kotlin (No Java standard library etc.) shared between projects for different platforms - iOS, Android, Web.

Since this library is just a wrapper around RxJava it would be only possible to use it on Android or any JVM environment so any module using it wouldn't be shareable between platforms.

There are already corresponding Reactive Extensions projects for other two platform RxSwift and RxJs so there could be some abstraction built to just use according Rx library on each platform but I really doubt it would work since these libraries just share some common principles with RxJava and not all operators are semantically the same.

Completely rewriting RxJava in Kotlin wouldn't be the easiest task I guess but certainly the most sought after.

Any thoughts on this?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.