rxify
rxify copied to clipboard
Now: RxJava Playground, Previous: Demo for the talk at DroidconIN 2016, Droidcon Boston 2017 and Codelab for GDG January Meetup
Rxify
Started with a simple demo for the talk at droidconIN 2016, Banglore. Added more examples from GDG New Delhi Meetup. Will keep adding more demos and new things here :)
- For more information, checkout multi-part
Rxify
blog series on medium. - For the video of this talk click here
- For the slides click here
- Slides for the Codelab can be found here
Project Structure
This project :
- Uses RxJava2 for the demos.
- Follows the
MVP
architecture inspired by repository. - Makes use of
Dagger2
- Uses Butterknife
- Uses
TestScheduler
for writing tests.
Zip-yosa (ZipActivity
)
Perform API calls asynchronously and wait for the result of both the calls to combine the result. For more information, checkout this article.
-
We are waiting for
FluxWeed
API call. -
We are also waiting for
Student
API call to get hair of Crab. -
Both the calls executing asynchronously.
-
Problem :
- Initialise
PolyJuice
from the results of API calls. - Hide the loader after both calls have completed.
Here's the demo :
- Initialise
Preserving Order in AutoComplete-Search (LibraryActivity
)
Depicting the problem of Ordering the results in Auto-Search and solving it using concatMap(). For more information, checkout this article
- Perform Auto-Complete Search using
flatMap()
- results in unordered results - Toggle state to fix it using
concatMap()
- used
BookDataSource
and callinggetBooks(query)
on the data source return the results after a delay which is inversely proportional to the length of query string. - this is done to depict the ordering problem - used the open-source library used at my current company Fueled - reclaim which extracts the boiler plate for creation of recyclerview adapter, implementation of MVP for listview items.
Using flatMap()
- Order is not maintained.
Using concatMap()
- Order is maintained.
Ordering problem is fixed, but we shouldn't be updating the list this frequently.
switchMap()
will improve the results even further :
Using switchMap()
- Order is maintained.
Code-lab
This is the code-lab I conducted at the GDG New Delhi January meetup. SpeakerDeck for this is available here. Completed examples for all the operators are also available on the master
branch. For in-detail commit-by-commit codelab. Refer to the codelab
branch.
Pre-requisites :
- Android Studio IDE
-
git
- Lots of excitement.
Let's Get Started
- Switch to branch
codelab
. - Checkout at the starting commit : SHA -
d5db64950f1616c308bb8174bb8dc01ab69971e8
. - List of all the commits is here.
- Open
ChillActivity
and switch to the desired presenter. - Let's Get Started!! Following Excercises are available :
Section 1 - Basic Spells :
-
EmptyPresenter
-
ErrorPresenter
-
FromPresenter
-
IntervalPresenter
-
IntervalRangePresenter
-
JustPresenter
-
NeverPresenter
-
RangePresenter
-
TimerPresenter
Section 2 - To-Do Section :
-
AssignmentPresenter
-
BattleFlowPresenter
-
BattlePresenter
-
DistinctPresenter
-
FilterPresenter
-
FlatMapPresenter
-
MapPresenter
-
ReducePresenter
-
SkipPresenter
-
TakePresenter
-
TakeUntilPresenter
Section 3 - Threading :
-
ThreadingPresenter
Section 4 - Testing :
-
EmptyPresenter
-
NeverPresenter
-
MagicalRemoteDataSourceTest
TO-DO
- Implement more demos.