Creating Observable without using Observable.create

后端 未结 2 1093
野趣味
野趣味 2020-12-08 04:48

I am using RxJava in my Android app and I want to load data from the database.

In this way, I am creating a new Observable using Observable.create() whi

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 05:22

    As it's explain in the response you linked, with Observable.create you'll may need to violate the advanced requirements of RxJava.

    For example, you'll need to implement backpressure, or how to unsubscribe.

    In you case, you want to emit an item, without having to deal with backpressure or subscription. So Observable.fromCallable is a good call. RxJava will deal with the rest.

提交回复
热议问题