前言
根据Froussios英文版的学习笔记,这里是简单的学习笔记。
一、Subscribe 订阅
Subscription subscribe()
Subscription subscribe(Action1<? super T> onNext)
Subscription subscribe(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Subscription subscribe(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)
Subscription subscribe(Observer<? super T> observer)
Subscription subscribe(Subscriber<? super T> subscriber)
二、Unsubscribe取消订阅
boolean isUnsubscribed()
void unsubscribe()
三、Subscription
Subscription对象是被观察者和订阅者之间的桥梁。- Subscriptions.empty()返回一个什么都不做的Subscription对象。
Subscription empty = Subscriptions.empty();
System.out.println(empty.isUnsubscribed()); // false
empty.unsubscribe();
System.out.println(empty.isUnsubscribed()); // true
- Subscriptions.from(Subscription... subscriptions)将一组订阅聚合到一起订阅和取消。
- Subscriptions.unsubscribed()
Subscription unsubscribed = Subscriptions.unsubscribed();
System.out.println(unsubscribed.isUnsubscribed()); // true
后记
一定要收藏好https://rxmarbles.com/ 这个网址,记不得的时候去看看就好啦,图片很详细的。