[Android 知识点] RxAndroid的使用(五)(待更新)

Error Handling Operators 错误处理

  • Catch — recover from an onError notification by continuing the sequence without error
  • Retry — if a source Observable sends an onError notification, resubscribe to it in the hopes that it will complete without error

Observable Utility Operators 通用操作

  • Delay — shift the emissions from an Observable forward in time by a particular amount
  • Do — register an action to take upon a variety of Observable lifecycle events
  • Materialize/Dematerialize — represent both the items emitted and the notifications sent as emitted items, or reverse this process
  • ObserveOn — specify the scheduler on which an observer will observe this Observable
  • Serialize — force an Observable to make serialized calls and to be well-behaved
  • Subscribe — operate upon the emissions and notifications from an Observable
  • SubscribeOn — specify the scheduler an Observable should use when it is subscribed to
  • TimeInterval — convert an Observable that emits items into one that emits indications of the amount of time elapsed between those emissions
  • Timeout — mirror the source Observable, but issue an error notification if a particular period of time elapses without any emitted items
  • Timestamp — attach a timestamp to each item emitted by an Observable
  • Using — create a disposable resource that has the same lifespan as the Observable

subscribeOn(Schedulers.io())

subscribeOn会修改我们刚刚创建的Observable。在默认情况下Observable的所有代码,包括刚才说到的只有在被订阅之后才会执行的代码,都会在执行subscribe()方法的线程中运行。而通过subscribeOn()方法,这些代码可以在其他线程中执行。

observeOn(AndroidSchedulers.mainThread())

告诉RxJava我们要在UI线程中观察这个Observable

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值