
com.noheltcj.rxcommon.Source.kt Maven / Gradle / Ivy
package com.noheltcj.rxcommon
import com.noheltcj.rxcommon.disposables.Disposable
import com.noheltcj.rxcommon.observers.CompleteObserver
import com.noheltcj.rxcommon.observers.NextObserver
import com.noheltcj.rxcommon.observers.Observer
import com.noheltcj.rxcommon.observers.TerminalObserver
import com.noheltcj.rxcommon.operators.*
interface Source {
fun subscribe(observer: Observer): Disposable
fun combineLatest(otherSource: Source, transform: (E, O) -> R): Source = CombineLatest(this, otherSource, transform)
fun map(transform: (E) -> R): Source = MapOperator(this, transform)
fun flatMap(resolveAdditionalSource: (E) -> Source): Source = FlatMap(this, resolveAdditionalSource)
fun switchMap(resolveNewSource: (E) -> Source): Source = SwitchMap(this, resolveNewSource)
fun doOnEach(observer: Observer): Source = DoOnEach(this, observer)
fun doOnNext(onNext: (E) -> Unit): Source = DoOnEach(this, NextObserver(onNext))
fun doOnComplete(onComplete: () -> Unit): Source = DoOnEach(this, CompleteObserver(onComplete))
fun doOnError(onError: (Throwable) -> Unit): Source = DoOnEach(this, TerminalObserver(onError))
fun onErrorReturn(resolveNewSource: (Throwable) -> Source) = OnErrorReturn(this, resolveNewSource)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy