December 2017
Intermediate to advanced
322 pages
7h 3m
English
The filter operator is arguably the most used filtering/suppressing operator. It lets you implement custom logic to filter emissions.
The following code snippet is the simplest implementation of the filter operator:
fun main(args: Array<String>) {
Observable.range(1,20)//(1)
.filter{//(2)
it%2==0
} .subscribe {
println("Received $it")
}
}
On comment (1), we created an Observable instance with the help of the Observable.range() operator. We filtered out odd numbers from the emissions with the help of the filter operator on comment (2).
The following is the output:

Read now
Unlock full access