Upload
tankery-chen
View
64
Download
7
Embed Size (px)
Citation preview
RxJava Tankery @ Mobvoi inc.
Agenda
RxJava
RxJava
RxJava API
Ex Extensions
RxJava
Callbackcallback-hell
Future, CompletableFuture (Java8)Future CompletableFuture Java 8
RxJava
Callback RxJava
115
Source: https://github.com/ReactiveX/RxJava/wiki/How-To-Use-RxJava
https://github.com/ReactiveX/RxJava/wiki/How-To-Use-RxJava
side-effects
Functional Programming
Source: https://medium.com/@cscalfani/so-you-want-to-be-a-functional-programmer-part-1-1f15e387e536#.9utprtico
https://medium.com/@cscalfani/so-you-want-to-be-a-functional-programmer-part-1-1f15e387e536#.9utprticohttps://medium.com/@cscalfani/so-you-want-to-be-a-functional-programmer-part-1-1f15e387e536#.9utprtico
Source: https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-programming
https://maryrosecook.com/blog/post/a-practical-introduction-to-functional-programming
RxJava
RxJava - Reactive eXtensions (ReactiveX) for the JVM
ReactiveX
RxJava -
/create, from, just
operators (map, flatMap, filter, merge, combineLatest, etc.)
subscribe
RxJava -
RxJava -
onNext, onError, onComplete (onErrorReturn, onErrorResumeNext, retry)
Operators debounce, timeout, groupBy, etc.
RxJava API
RxJava API - Overview Observable: create, from, just
OnSubscribe
Observer: onNext, onError, onComplete
Subscriber: implements Observer, SubscriptionSubscriptionOperator: Lifting Subscriber to Subscriber http://reactivex.io/documentation/operators.html
Subject: Bridge between Observable and Subscriber
Scheduler: Source of concurrency for observables. (subscribe | observe) On
RxJava API - Observable
RxJava API - Observer
RxJava API - Operator
Source: http://reactivex.io/documentation/observable.html
http://reactivex.io/documentation/observable.html
RxJava API - Functional API
Unfold: T -> Observable just, range, timer, interval, create, never, empty, error
Map: Observable -> Observable map, filter
Fold (or reduce): Observable -> T reduce, toList
RxJava API - Cold vs Hot Observable Observable
cold Observable Observable
hot Observable Observable Observable
Subject always hot
Rx Extensions
Rx Extensions RxAndroid
https://github.com/ReactiveX/RxAndroid
AndroidSchedulers.mainThread() HandlerScheduler.from(Handler) *
RxBindinghttps://github.com/JakeWharton/RxBinding
RxView.clicks()
* Latest API: AndroidSchedulers.from(Looper)
https://github.com/ReactiveX/RxAndroidhttps://github.com/JakeWharton/RxBinding
Rx Powered Libs RxLifecycle - Lifecycle handling APIs for Android apps using RxJava
RxBinding - RxJava binding APIs for Android's UI widgets.
SqlBrite - A lightweight wrapper around SQLiteOpenHelper and ContentResolver which introduces reactive stream semantics to queries.
Android-ReactiveLocation - Library that wraps location play services API boilerplate with a reactive friendly API.
rx-preferences - Reactive SharedPreferences for Android
RxFit - Reactive Fitness API Library for Android
RxWear - Reactive Wearable API Library for Android
RxPermissions - Android runtime permissions powered by RxJava
RxNotification - Easy way to register, remove and manage notifications using RxJava
RxClipboard - RxJava binding APIs for Android clipboard.
Source: https://github.com/ReactiveX/RxAndroid/wiki
https://github.com/ReactiveX/RxAndroid/wiki
-
RxJava RxJava (Observable) (Operation) (Subscription)
- Unsubscribe cold observable hot observable memory leak
SubscriptionList subscription onDestroy unsubscribe
SubscriptionList unsubscribe add Subscription unsubscribe unsubscribe listnew
Subscriptions.create(Action) unsubscribe ActionAPI
- (Operators) Operator
complete observable reduce, toList, scan Observable complete complete observable
distinctUntilChanged
- RxJava OnSubscribe subscribe
side effects
side effects timeout, debounce
Subject onNext toSerialized() subject
Tankery Chen
Thats all Any Questions?
References ReactiveX
http://reactivex.io/https://mcxiaoke.gitbooks.io/rxdocs/content/
RxJavahttp://blog.csdn.net/lzyzsd/article/details/41833541http://blog.csdn.net/lzyzsd/article/details/44094895http://blog.csdn.net/lzyzsd/article/details/44891933Androidhttp://blog.csdn.net/lzyzsd/article/details/45033611
NotRxJavaRxJavahttp://www.devtf.cn/?p=323
RxJava - introduction & designhttp://www.slideshare.net/allegrotech/rxjava-introduction-context
RxJava http://blog.tankery.me/development/intro-to-rxjava
http://reactivex.io/https://mcxiaoke.gitbooks.io/rxdocs/content/http://blog.csdn.net/lzyzsd/article/details/41833541http://blog.csdn.net/lzyzsd/article/details/44094895http://blog.csdn.net/lzyzsd/article/details/44891933http://blog.csdn.net/lzyzsd/article/details/45033611http://www.devtf.cn/?p=323http://www.slideshare.net/allegrotech/rxjava-introduction-contexthttp://blog.tankery.me/development/intro-to-rxjava