O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dropping items

Dropping means that if the downstream processing steps cannot keep up with the pace of the source Observable, they will just drop the data that cannot be handled. This can only be used in cases when losing data is okay, and you care more about the values that were emitted in the beginning.

There are a few ways in which items can be dropped.

The first one is just to specify Backpressure strategy, like this:

observable.toFlowable(BackpressureStrategy.DROP)

Alternatively, it will be like this:

observable.toFlowable(BackpressureStrategy.MISSING)        .onBackpressureDrop()

A similar way to do that would be to call .sample(). It will emit items only periodically, and it will take only the last value that's available (while BackpressureStrategy.DROP ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required