4

I'm new to RxJava and currently, I'm understanding things through examples. One thing is always confusing me, and so far I couldn't find any better document to understand it clearly. Flowable Vs Observable, when to use which

As per my understanding, Flowable supports backpressure whereas Observable doesn't. Which means If you don't want to lose any stream (Such as UI events like mouse move, keyboard text entry) You should go for Observable.

If your emitter is emitting continues items, and you have a slower consumer, go for Flowable, It will manage out of memory errors by caching only limited amount of items

Alright, But in many samples and docs, I saw people using and recommend Flowable for network requests and disk operations. Including the googlesamples. But why? Why is Flowable best over Observable here? You will be hitting the API for a single response, and you would expect a limited set of result only, It is not like a continues emitter as the mouse move listener. So what makes it better to use Flowable here over observable?

Also, for a beginner like me, it would be helpful if someone could explain some of the common use cases to go for Flowable or Observable in simple words.

  • 2
    Possible duplicate of [RxJava 2.x: Should I use Flowable or Single/Completable?](https://stackoverflow.com/questions/42525623/rxjava-2-x-should-i-use-flowable-or-single-completable) – andrei_zaitcev Sep 30 '17 at 08:53
  • I think this is a duplicate of https://stackoverflow.com/questions/42525623/rxjava-2-x-should-i-use-flowable-or-single-completable. tl;dr use Single or Completable for network requests instead of Flowable/Observable. It's a good API design and gives other developers a clear idea of type of the source. For instance, it makes no sense to subscribe for continuous updates for something like "getting a list of tasks from the backend". You either get them or catch an error like IOException. – andrei_zaitcev Sep 30 '17 at 08:55

0 Answers0