Source link: https://github.com/ravi8x/RxAndroidExamples
Here sample Rx Android Examples
Intro
The aim of this course is to teach fundamental concepts of RxJava and RxAndroid and take you from a novice to intermediate RxJava developer.
Head on to https://www.androidhive.info/RxJava for detailed explanation of RxJava modules.
Basics
- Example1Activity - Basic
Observable
,Observer
and Subscription example. Emitting list of animal names. - Example2Activity - Introduced Disposable to dispose the subscription.
- Example3Activity - Introducing
filter()
operator to filter out the animal names starting with letterb
. - Example4Activity - Example of chaining of operators.
map()
andfilter()
operators are used together. - Example5Activity - Introduced
CompositeDisposable
andDisposableObserver
. Also custom data typeNote
is used in this example.
Operators
Read the Introduction to RxJava Operators to get started with RxJava operators.
- JustOperator - Creating an Observable using
just
operator. - FromOperator - Creating an Observable using
from
operator. - RangeOperator - Creating an Observable using
range
operator. - BufferOperator -
Buffer
emits data into batches instead of emitting one at a time. Calculating number of taps in certain period is explained in the example. - DebounceOperator -
Debounce
operators emits items only when a specified timespan is passed. An example of taking search query is explained. - FilterOperator -
filter
allows the Observable to emit the only values those passes a test. - RepeatOperator - Creates an Observable that emits an item or series of items repeatedly.
- SkipOperator -
skip(n)
operator skips the emission of first N items emitted by an Observable. - TakeOperator -
take(n)
takes first N emissions of an Observable. - DistinctOperator -
Distinct
operator filters out items emitted by an Observable by avoiding duplicate items in the list. - CountOperator - Counts number of items emitted by an Observable and emits only the count value.
- ReduceOperator - Example of
reduce
operator. Applies a function to first item, takes the result and feeds back to same function on second item. This process continuous until the last emission. Once all the items are over, it emits the final result. - MaxOperator - Finds the
maximum
valued item in the Observable sequence and emits that value - MinOperator - Finds the
minimum
valued item in the Observable sequence and emits that value - SumOperator - Calculates the sum of all the items emitted by an Observable and emits only the Sum value.
- AverageOperator - Calculates the average of all the items emitted by an Observable and emits only the Average value.
- ConcatOperator -
Concat
operator combines output of two or more Observables into a single Observable. Maintains the order of execution. - MergeOperator -
Merge
also merges multiple Observables into a single Observable but it won’t maintain the sequential execution. - MapOperator -
Map
operator transform each item emitted by an Observable and emits the modified item. - FlatMapOperator - Example of
FlatMap
operator. - ConcatMapOperator - Example of
ConcatMap
operator. - SwitchMapOperator - Example of
SwitchMap
operator. - ZipOperator - Example of
Zip
operator.
Retrofit Networking
Android RxJava Networking with Retrofit, Gson RxJava networking using Retrofit library. An example of live Notes App is explained using Retrofit networking. Demo
Android Examples
-
Android RxJava Instant Search – Local, Remote Databases (Retrofit) Android example of adding instant search to a Contacts app. You will see a use case of Debounce, SwitchMap, Observables and Retrofit when put together.
-
Android Flight Ticket App – RxJava FlatMap (Retrofit) Android example of simple Flight Ticket price listing app. You will learn the use of FlatMap and ConcatMap operators when used with Retrofit networking calls.
Roadmap
- RxBinding
- RxJava Subjects
- RxJava Event Bus
- Understanding Marble Diagrams
- Data Storage (SQLite, Room Persistence)
- Flowable Backpressure Example
- Hot vs Cold Observables
- Side Effect Operators
- Volley Networking
- Form Validation
- Rx Runtime Permissions
- Timers & Intervals
- Clean Architecture
- MVP, MVVM Architecture
- Complete RxJava Apps