RxJava 2.0 has been completely rewritten from scratch on top of the Reactive-Streams specification. The specification itself has evolved out of RxJava 1.x and provides a common baseline for reactive systems and libraries.
Because Reactive-Streams has a different architecture, it mandates changes to some well known RxJava types.
To allow having RxJava 1 and RxJava 2 side-by-side, RxJava 2 is under the maven coordinates io.reactivex.rxjava2:rxjava:2.x.y and classes are accessible below io.reactivex.
Users switching from 1.x to 2.x have to re-organize their imports, but carefully.
Add this in your build.gradle
compile 'io.reactivex.rxjava2:rxjava:2.2.2'
If you are using RxAndroid also, then add the following
compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
RxJava 2.0 Example using CompositeDisposable
as CompositeSubscription
and Subscription
have
been removed.
RxJava 2 Example using Flowable
.
RxJava 2 Example using SingleObserver
, CompletableObserver
.
RxJava 2 Example using RxJava2 operators such as map, zip, take, reduce, flatMap, filter, buffer, skip, merge, concat, replay
, and much more:
RxJava 2 Android Samples using Function
as Func1
has been removed.
RxJava 2 Android Samples using BiFunction
as Func2
has been removed.
And many others android examples
RxJava1 -> RxJava2
onCompleted
-> onComplete
- without the trailing dFunc1
-> Function
Func2
-> BiFunction
CompositeSubscription
-> CompositeDisposable
limit
operator has been removed - Use take
in RxJava2Map
-> transform the items emitted by an Observable by applying a function to each itemZip
-> combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this functionFilter
-> emit only those items from an Observable that pass a predicate testFlatMap
-> transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single ObservableTake
-> emit only the first n items emitted by an ObservableReduce
-> apply a function to each item emitted by an Observable, sequentially, and emit the final valueSkip
-> suppress the first n items emitted by an ObservableBuffer
-> periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a timeConcat
-> emit the emissions from two or more Observables without interleaving themReplay
-> ensure that all observers see the same sequence of emitted items, even if they subscribe after the Observable has begun emitting itemsMerge
-> combine multiple Observables into one by merging their emissionsSwitchMap
-> transform the items emitted by an Observable into Observables, and mirror those items emitted by the most-recently transformed ObservableCompositeDisposable
Flowable
and reduce
operatorSingleObserver
CompletableObserver
map
Operatorzip
Operator, Blog for referencebuffer
Operatortake
Operatorreduce
Operatorfilter
Operatorskip
Operatorreplay
Operatorconcat
Operatormerge
Operatordefer
ObservableswitchMap
ObservableInterval
debounce
, switchMap
, distinctUntilChanged
, Blog for referenceconcat
, firstElement
, Blog for reference Copyright (C) 2016 Amit Shekhar
Copyright (C) 2011 Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Just make pull request. You are in!