Learn RxKotlin with simple coding examples
To allow having RxKotlin 1 and RxKotlin 2 side-by-side, RxKotlin 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.1.1'
If you are using RxAndroid also, then add the following
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
onCompleted
->onComplete
- without the trailing dFunc1
->Function
Func2
->BiFunction
CompositeSubscription
->CompositeDisposable
limit
operator has been removed - Usetake
in RxKotlin2
....... and so on
-
Map
-> Transform the items emitted by an Observable by applying a function to each item -
Zip
-> Combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function -
Take
-> Emit only the first n items emitted by an Observable -
Timer
-> Create an Observable that emits a particular item after a given delay -
FlatMap
-> Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable -
Interval
-> Create an Observable that emits a sequence of integers spaced by a given time interval -
Debounce
-> Only emit an item from an Observable if a particular time span has passed without it emitting another item -
Single Observer
-> A Single is something like an Observable, but instead of emitting a series of values — anywhere from none at all to an infinite number — it always either emits one value or an error notification. -
Reduce
-> Apply a function to each item emitted by an Observable, sequentially, and emit the final value -
Buffer
-> Periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time -
Filter
-> Emit only those items from an Observable that pass a predicate test -
Skip
-> Suppress the first n items emitted by an Observable -
Sacn
-> Apply a function to each item emitted by an Observable, sequentially, and emit each successive value -
Replay
-> Ensure that all observers see the same sequence of emitted items, even if they subscribe after the Observable has begun emitting items -
Concat
-> Emit the emissions from two or more Observables without interleaving them -
Merge
-> Combine multiple Observables into one by merging their emissions -
Defer
-> The Defer operator waits until an observer subscribes to it, and then it generates an Observable, typically with an Observable factory function. It does this afresh for each subscriber, so although each subscriber may think it is subscribing to the same Observable, in fact each subscriber gets its own individual sequence. -
Distinct
-> Suppress duplicate items emitted by an Observable -
Coming More
Adding more operator examples
-
SimpleOperatorActivity - Using
Simple
operator -
MapOperatorActivity - Using
Map
operator -
ZipOperatorActivity - Using
Zip
observer -
DisposableOperatorActivity - Using
Disposable
operator -
FlatMapOperatorActivity - Using
FlatMap
Operator -
IntervalOperatorActivity - Using
Interval
Operator -
TakeOperatorActivity - Using
Take
Operator -
TimerOperatorActivity - Using
Timer
Operator -
DebounceOperatorActivity - Using
Debounce
Operator -
SingleObserverOperatorActivity - Using
Single Observer
Operator -
FlowableOperatorActivity - Using
Flowable
-
ReduceOperatorActivity -Using
Reduce
Operator -
BufferOperatorActivity -Using
Buffer
Operator -
FilterOperatorActivity -Using
Filter
Operator -
SkipOperatorActivity -Using
Skip
Operator -
ScanOperatorActivity -Using
Scan
Operator -
ReplayOperatorActivity -Using
Replay
Operator -
ConcatOperatorActivity -Using
Concat
Operator -
MergeOperatorActivity -Using
Merge
Operator -
DeferOperatorActivity -Using
Defer
Operator -
DistinctOperatorActivity -Using
Distinct
Operator -
ReplaySubjectOperatorActivity -Using
Replay Subject
Operator -
PublishSubjectOperatorActivity -Using
Publish Subject
Operator -
BehaviorSubjectActivity -Using
Behavior Subject
Operator -
Coming More
Copyright 2017 Ankit Kumar
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.