In this example, we are going to introduce the from()
function. With this particular "create" function, we can create an Observable from a list. The Observable will emit every element in the list, and we can subscribe to react to these emitted elements.
To achieve the same result of the first example, we are going to update our adapter on every onNext()
function, adding the element and notifying the insertion.
We are going to reuse the same structure as the first example. The main difference is that we are not going to retrieve the installed applications' list. The list will be provided by an external entity:
mApps = ApplicationsList.getInstance().getList();
After obtaining the list, we only need to make it reactive and populate the RecyclerView
item:
private void loadList(List<AppInfo> apps) { mRecyclerView.setVisibility(View.VISIBLE); Observable.from(apps) .subscribe(new Observer<AppInfo>() { @Override ...