Reactive Programming with RxJava-Chapter2:Reactive Extensions
来源:互联网 发布:c语言实验交换字母 编辑:程序博客网 时间:2024/04/30 22:12
Anatomy of rx.Observable
Indeed,Observablecan actually produce three types of events:
- Values of type T,as declared by Observable
- Completion event
- Error event
Subscribing to Notifications from Observable
Controlling Listener by Using Subscription and Subscriber
Creating Observables
1、Mastering Observable.create()
Managing Multiple subsscribers
- cache()
2、Infinite Streams
Two techniques for subscriber to clean up resource when unsubscribes
- if(subscriber.isUnsubscribed()){…}
- subscriber.add(Subscriptions.create(…))
You should not use explicit threads inside create()
It is a good practise to wrap entire expressions within create() in a try-catch block.Throwables should be propagated downstream rather than logged or rethrown.
Timing:timer() and interval()
- timer()
- interval()
Hot and Cold Observables
How to multiplex a single upstream source to multiple Observers
1、rx.subjects.Subject
Subjects are useful,but there are many subtleties you must understand.For example,after calling subject.onError(),the Subject silently drops subsequent onError notifications,effectively swallowing them
- PublishSubject
- AsyncSubject
- BehaviorSubject
- ReplaySubject
2、ConnectableObservable
Single Subscription (Observable.share())
No matter how many Subscribes connect to ConnectableObservable,it opens just one subscription to the Observable from which it was created
- Observable.publish()
- ConnectableObservable.refcount();
ConnectableObservable Lifecycle
Force subscription in absence of any Subscriber
- Observable.publish()
- ConnectableObservable.connect();
autoConnect() (since 1.2)
- Observable.publish()
- ConnectableObservable.autoConnect();
最后,安利一款自己写的基于MVP的Android开发框架
https://github.com/sxenon/Pure
欢迎大家拍砖,如果觉得好,麻烦多多star
- Reactive Programming with RxJava-Chapter2:Reactive Extensions
- Reactive Programming with RxJava-Chapter1:Reactive Programming with RxJava
- Functional Reactive Programming on Android With RxJava
- RxJava实现响应式编程(Reactive Programming with RxJava)
- Reactive Programming with RxJava-Chapter4:Applying Reactive Programming to Existing Application(1)
- Reactive Programming with RxJava-Chapter4:Applying Reactive Programming to Existing Application(2)
- RxJava(一:functional reactive programming)
- Reactive Programming with RxJava-Chapter5:Reactive from Top to Bottom(1)
- Reactive Programming with RxJava-Chapter5:Reactive from Top to Bottom(2)
- Reactive Programming with RxJava-Chapter3:Operators and Transformations(1)
- Reactive Programming with RxJava-Chapter3:Operators and Transformations(2)
- Reactive Programming with RxJava-Chapter3:Operators and Transformations(3)
- Reactive Programming with Rxjava-Chapter6:Flow Control and Backpressure(1)
- Reactive Programming with RxJava-Chapter6:Flow Control and Backpressure(2)
- Reactive Programming with RxJava-Chapter7:Test and Troubleshooting(1)
- Reactive Programming with RxJava,介绍一本书和Rx
- Reactive Programming with RxJava.pdf 英文原版 免费下载
- RxJava: Reactive Extensions for the JVM
- 信号傅立叶变换后实际频谱图(Matlab)
- Javascript 中的神器——Promise
- (转)jQuery height()、innerHeight()、outerHeight()函数的区别详解
- 随机梯度下降算法学习心得
- Windows7旗舰版+Visual Studio2013的OpenGl配置
- Reactive Programming with RxJava-Chapter2:Reactive Extensions
- var a=b=5;
- 洛谷 P1403 [AHOI2005]约数研究
- 0221HTML学习_框架
- Android ContentProvider的基本使用1(内容提供者)
- 使用react/lib/update 对数据进行操作
- 《放牛班的春天》
- Python学习笔记之三:lambda表达式,filter函数,map函数
- Android之内容提供者-- 获取联系人和短信信息