Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why not always use Flowable in rxjava2

Tags:

rx-java2

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?

like image 350
Jan Bols Avatar asked Jan 12 '17 09:01

Jan Bols


1 Answers

  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.

like image 133
Yaroslav Stavnichiy Avatar answered May 24 '23 00:05

Yaroslav Stavnichiy