Jan Bols
Jan Bols

Reputation: 477

Why not always use Flowable in rxjava2

In rxJava2 there's a distinction between Observables (not backpressured) and Flowables (backpressured). https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#when-to-use-observable gives some reasons to use observables, but as far as I can see, the functionality of observables is a subset from those of flowables.

Is there any reason not to always use flowables instead? Are observables faster perhaps? Or can you do things with observables that you cannot do with flowables?

Upvotes: 7

Views: 457

Answers (1)

Yaroslav Stavnichiy
Yaroslav Stavnichiy

Reputation: 21486

  1. Observables are faster:

Using Observable has lower overhead in general than Flowable

  1. Backpressure might be undesirable:

The main issue with backpressure is that many hot sources, such as UI events, can't be reasonably backpressured

  1. Backpressure complicates things when you try to extend RxJava with custom objects or operators.

Although there are other frameworks, eg. Project Reactor, that do not make such distinction and implement only objects with backpressure.

Upvotes: 6

Related Questions