![JAR search and dependency download from the Maven repository](/logo.png)
reactivecircus.blueprint.interactor.rx2.ObservableInteractor.kt Maven / Gradle / Ivy
package reactivecircus.blueprint.interactor.rx2
import io.reactivex.Observable
import io.reactivex.Scheduler
import reactivecircus.blueprint.interactor.InteractorParams
/**
* Abstract class for a use case, representing an execution unit of asynchronous work.
* This use case type uses [Observable] as the return type.
* Upon subscription a use case will execute its job in the thread specified by the [ioScheduler].
* and will post the result to the thread specified by [uiScheduler].
*/
public abstract class ObservableInteractor(
private val ioScheduler: Scheduler,
private val uiScheduler: Scheduler
) {
/**
* Create a [Observable] for this interactor.
*/
protected abstract fun createInteractor(params: P): Observable
/**
* Build a use case with the provided execution thread and post execution thread
*/
public fun buildObservable(params: P): Observable {
return createInteractor(params)
.subscribeOn(ioScheduler)
.observeOn(uiScheduler)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy