O'Reilly logo

RxJava Essentials by Ivan Morgillo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A few more examples

In this section, we are going to show a few examples based on RxJava's just(), repeat(), defer(), range(), interval(), and timer() methods.

just()

Let's assume we only have three separated AppInfo objects and we want to convert them into an Observable and populate our RecyclerView item:

List<AppInfo> apps = ApplicationsList.getInstance().getList();

AppInfo appOne = apps.get(0);

AppInfo appTwo = apps.get(10);

AppInfo appThree = apps.get(24);

loadApps(appOne, appTwo, appThree);

We can retrieve the list like we did in the previous example and extract only three elements. Then, we pass them to the loadApps() function:

private void loadApps(AppInfo appOne, AppInfo appTwo, AppInfo appThree) { mRecyclerView.setVisibility(View.VISIBLE); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required