All Projects → ReactiveX → Rxkotlin

ReactiveX / Rxkotlin

Licence: apache-2.0
RxJava bindings for Kotlin

Programming Languages

kotlin
9241 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to Rxkotlin

Retrofitcache
RetrofitCache让retrofit2+okhttp3+rxjava配置缓存如此简单。通过注解配置,可以针对每一个接口灵活配置缓存策略;同时让每一个接口方便支持数据模拟,可以代码减小侵入性,模拟数据可以从内存,Assets,url轻松获取。
Stars: ✭ 647 (-90.44%)
Mutual labels:  rxjava
Rxwebsocket
An auto reconnection-webSocket build with okhttp and rxJava
Stars: ✭ 678 (-89.99%)
Mutual labels:  rxjava
Ganhuoio
基于Gank.IO提供的API的第三方客户端(RxJava+Retrofit)
Stars: ✭ 727 (-89.26%)
Mutual labels:  rxjava
Mango
🏀 An Android app for dribbble.com
Stars: ✭ 659 (-90.27%)
Mutual labels:  rxjava
Wanandroid
🐔🏀【停止维护,已使用Jetpack+Mvvm重构】根据鸿神提供的WanAndroid开放Api来制作的产品级玩安卓App,采用Kotlin语言,基于Material Design+AndroidX +MVP+RxJava+Retrofit等框架开发,注释超详细,方便大家练手
Stars: ✭ 674 (-90.05%)
Mutual labels:  rxjava
Rxgroups
Easily group RxJava Observables together and tie them to your Android Activity lifecycle
Stars: ✭ 695 (-89.74%)
Mutual labels:  rxjava
Lazywaimai Android
一个类似于饿了么、美团外卖和百度外卖的APP,采用MVP架构,目前还有部分功能还未实现,但基本的订餐流程已实现。
Stars: ✭ 623 (-90.8%)
Mutual labels:  rxjava
Mvvmhabit
goldze: 本人喜欢尝试新的技术,以后发现有好用的东西,我将会在企业项目中实战,没有问题了就会把它引入到MVVMHabit中,一直维护着这套框架,谢谢各位朋友的支持。如果觉得这套框架不错的话,麻烦点个 star,你的支持则是我前进的动力!
Stars: ✭ 6,789 (+0.27%)
Mutual labels:  rxjava
Reservoir
Android library to easily serialize and cache your objects to disk using key/value pairs.
Stars: ✭ 674 (-90.05%)
Mutual labels:  rxjava
Rxmarkdown
📠Markdown for Android, supports TextView && EditText (Live Preview), supports code high light.
Stars: ✭ 714 (-89.46%)
Mutual labels:  rxjava
Android Oss
Kickstarter for Android. Bring new ideas to life, anywhere.
Stars: ✭ 5,627 (-16.9%)
Mutual labels:  rxjava
Smartrecom
一款基于行为识别和个性化推荐的智能推荐APP,实时为你推荐音乐和电影,让你的生活更休闲,更精彩!
Stars: ✭ 663 (-90.21%)
Mutual labels:  rxjava
Gankdaily
A application used to show technical information in every working days, use MVP pattern.
Stars: ✭ 704 (-89.6%)
Mutual labels:  rxjava
Kovenant
Kovenant. Promises for Kotlin.
Stars: ✭ 657 (-90.3%)
Mutual labels:  rxjava
Easygank
💊 The project build framework based on the Rx series and MVP pattern.
Stars: ✭ 750 (-88.92%)
Mutual labels:  rxjava
T Mvvm
This repository contains a detailed sample app that implements MVVM architecture using LiveData,ViewModel,Retrofit,Rxjava
Stars: ✭ 630 (-90.7%)
Mutual labels:  rxjava
Baby
一个私密社交APP,采用Dagger2+Rxjava+LeanCloud+环信+MVP+Tinker进行开发。
Stars: ✭ 687 (-89.85%)
Mutual labels:  rxjava
Rxjavasample
RxJava Sample
Stars: ✭ 811 (-88.02%)
Mutual labels:  rxjava
Supermvp
MVP“美”图+新闻+天气预报+Material+RxJava3+Retrofit2+Glide4+AndroidX+Leakcanary+Butterknife
Stars: ✭ 763 (-88.73%)
Mutual labels:  rxjava
Grpc By Example Java
A collection of useful/essential gRPC Java Examples
Stars: ✭ 709 (-89.53%)
Mutual labels:  rxjava

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

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].