Understanding the Observable.from methods

The Observable.from methods are comparatively simpler than the Observable.create method. You can create Observable instances from nearly every Kotlin structure with the help of from methods.

Note that in RxKotlin 1, you will have Observale.from as a method; however, from RxKotlin 2.0 (as with RxJava2.0), operator overloads have been renamed with a postfix, such as fromArray, fromIterable, fromFuture, and so on.

So, let's take a look at this code:

 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 ...

Get Reactive Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.