Book Image

Reactive Programming in Kotlin

By : Rivu Chakraborty
Book Image

Reactive Programming in Kotlin

By: Rivu Chakraborty

Overview of this book

In today's app-driven era, when programs are asynchronous, and responsiveness is so vital, reactive programming can help you write code that's more reliable, easier to scale, and better-performing. Reactive programming is revolutionary. With this practical book, Kotlin developers will first learn how to view problems in the reactive way, and then build programs that leverage the best features of this exciting new programming paradigm. You will begin with the general concepts of Reactive programming and then gradually move on to working with asynchronous data streams. You will dive into advanced techniques such as manipulating time in data-flow, customizing operators and provider and how to use the concurrency model to control asynchronicity of code and process event handlers effectively. You will then be introduced to functional reactive programming and will learn to apply FRP in practical use cases in Kotlin. This book will also take you one step forward by introducing you to Spring 5 and Spring Boot 2 using Kotlin. By the end of the book, you will be able to build real-world applications with reactive user interfaces as well as you'll learn to implement reactive programming paradigms in Android.
Table of Contents (20 chapters)
Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Dedication
Preface

Skipping and taking emissions


Just like the preceding situation in this chapter, where we used the take operator, there are often some scenarios where you would like to take some of the emissions and skip the remaining ones. The skip and take operators are of huge help in those scenarios. They are actually a part of the filtering operators we discussed in the previous chapter; however, honestly, they do deserve a dedicated discussion. So, here it is.

Skipping emissions (skip, skipLast, skipUntil, and skipWhile)

There may be a requirement where you would like to skip some emissions at the beginning or skip emissions until a particular condition is met. You may even have to wait for another producer before taking emissions and skip all remaining ones.

These operators are designed keeping the exact scenario in mind. They help you skip emissions in various ways.

RxKotlin provides us with many variations and overloads of the skip operator; we will discuss the most important ones among them:

  • skip
  • skipLast...