What is the difference between Observable, Completable and Single in RxJava

前端 未结 3 1206
陌清茗
陌清茗 2020-12-22 15:40

Can anyone please explain the difference between Observable, Completable and Single in RxJava with clear examples?

In which scenario we use one over the others?

3条回答
  •  鱼传尺愫
    2020-12-22 16:33

    1. Flowable and Observable can represent finite or infinite streams. Flowable support back-pressure.
    2. Single are streams with a single element.
    3. Maybe are streams with either 0 or one element.
    4. Finally a Completable represents a stream with no elements, i.e it can only complete without a value or fail.

    A concise answer I found here on RXJava section.

提交回复
热议问题