The RxJava1 plugin provides RxJava 1 operators.
implementation("com.babylon.orbit2:orbit-rxjava1:<latest-version>")
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.
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.
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.