Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Latest commit

 

History

History

orbit-2-rxjava1

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Orbit 2 RxJava1 plugin

The RxJava1 plugin provides RxJava 1 operators.

implementation("com.babylon.orbit2:orbit-rxjava1:<latest-version>")

transformRx1Observable

fun subscribeToLocationUpdates(): Observable<LocationUpdate> { ... }

class ExampleViewModel : ContainerHost<ExampleState, ExampleSideEffect> {
    ...

    fun startLocationTracking() = orbit {
            transformRx1Observable { subscribeToLocationUpdates() }
                .reduce { state.copy(currentLocation = event) }
        }
    }
}

You can use this operator to subscribe to a hot or cold Observable. This operator acts similar to flatMap.

transformRx1Single

fun apiCall(): Single<SomeResult> { ... }
fun anotherApiCall(param: SomeResult): Single<OtherResult> { ... }

class ExampleViewModel : ContainerHost<ExampleState, ExampleSideEffect> {
    ...

    fun example() = orbit {
            transformRx1Single { apiCall() }
                .transformRx1Single { anotherApiCall(event) } // "event" is the result of the first api call
        }
    }
}

You can use this operator to subscribe to an RxJava 1 Single. This operator acts similar to flatMapSingle.

transformRx1Completable

fun doSomeWork(): Completable { ... }

class ExampleViewModel : ContainerHost<ExampleState, ExampleSideEffect> {
    ...

    fun example() = orbit {
            transformRx1Completable { doSomeWork() }
        }
    }
}

You can use this operator to subscribe to an RxJava 1 Completable. This operator acts similar to flatMapCompletable.