Rxjava解析之二---源码

RxJava核心事件解析
本文详细介绍了RxJava中四个核心事件:observe(观察者)、observable(被观察者)、subscribe(订阅事件)及事件本身的工作原理。重点阐述了观察者接收推送通知的三种情况:onCompleted(完成通知)、onError(错误通知)和onNext(新项通知)。文章指出这三种通知的不同应用场景及它们之间的相互排斥关系。

上篇博客知道了,Rxjava有四个事件组成:

observe(观察者),observable(被观察者),subscribe(订阅事件),事件

observe:没有具体的实现方法,只有三个方法,

1.onCompleted():

Notifies the Observer that the Observable has finished sending push-based notifications,The {@link Observable} will not call this method if it calls {@link #onError.

通知观察者基于被观察者的推送通知已经完成,如果调用onError方法,就不会调用这个方法。

2.onError(Throwable e):

Notifies the Observer that the {@link Observable} has experienced an error condition,If the {@link Observable} calls this method, it will not thereafter call {@link #onNext} or
     {@link #onCompleted}.

通知观察者被观察者遇到了错误,如果被观察者调用了这个方法,将不会再调用onNext或者onCompleted.

3.onNext(T t):

Provides the Observer with a new item to observe,The {@link Observable} may call this method 0 or more times,The {@code Observable} will not call this method again after it calls either {@link #onCompleted} or  {@link #onError}.

提供了一个新的item同观察,被观察者可能会调用这个方法0次或者多次,被观察者调用了onCompleted或者onError将不再调用这个方法。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值