Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Functional Kotlin

You're reading from   Functional Kotlin Extend your OOP skills and implement Functional techniques in Kotlin and Arrow

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher Packt
ISBN-13 9781788476485
Length 350 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Mario Arias Mario Arias
Author Profile Icon Mario Arias
Mario Arias
Rivu Chakraborty Rivu Chakraborty
Author Profile Icon Rivu Chakraborty
Rivu Chakraborty
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Kotlin – Data Types, Objects, and Classes FREE CHAPTER 2. Getting Started with Functional Programming 3. Immutability - It's Important 4. Functions, Function Types, and Side Effects 5. More on Functions 6. Delegates in Kotlin 7. Asynchronous Programming with Coroutines 8. Collections and Data Operations in Kotlin 9. Functional Programming and Reactive Programming 10. Functors, Applicatives, and Monads 11. Working with Streams in Kotlin 12. Getting Started with Arrow 13. Arrow Types 14. Kotlin's Quick Start 15. Other Books You May Enjoy

Subscriber – the Observer interface


In RxKotlin 1.x, the Subscriber operator essentially became an Observer type in RxKotlin 2.x. There is an Observer type in RxKotlin 1.x, but the Subscriber value is what you pass to the subscribe() method, and it implements Observer. In RxJava 2.x, a Subscriber operator only exists when talking about Flowables. 

As you can see in the previous examples in this chapter, an Observer type is an interface with four methods in it, namely onNext(item:T), onError(error:Throwable), onComplete(), and onSubscribe(d:Disposable). As stated earlier, when we connect Observable to Observer, it looks for these four methods in the Observer type and calls them. Here is a short description of the following four methods:

  • onNext: The Observable calls this method of Observer to pass each of the items one by one
  • onComplete: When the Observable wants to denote that it's done with passing items to the onNext method, it calls the onComplete method of Observer
  • onError: When Observable...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime