Difference between Observable.create() and Observable.fromCallable()

后端 未结 1 1978
甜味超标
甜味超标 2021-02-08 13:05

Suppose we are getting a generic Object from SharedPrefs using .create():

return Observable.create(subscriber -> {
             


        
相关标签:
1条回答
  • Observable.create let's you emit multiple items while fromCallable emits only a single item.

    You should use the latter as it is more expressive about the intent of having a single element sequence and has a slighly lower overhead.

    Drawback is that you can't have an async single element source with it whereas create let's you delay the call to onNext to a later point in time.

    0 讨论(0)
提交回复
热议问题