The Observable.create method
At any time, you can create your own custom implementation of Observable
with the Observable.create
method. This method takes an instance of the ObservableEmitter<T>
interface as a source to observe. Take a look at the following code example:
fun main(args: Array<String>) { val observer: Observer<String> = object : Observer<String> { override fun onComplete() { println("All Completed") } override fun onNext(item: String) { println("Next $item") } override fun onError(e: Throwable) { println("Error Occured => ${e.message}") } override fun onSubscribe(d: Disposable) { println("New Subscription ") } }//Create Observer val observable:Observable<String> = Observable.create<String> {//1 it.onNext("Emitted 1") it.onNext("Emitted 2") it.onNext("Emitted 3")...