Last active
August 29, 2015 14:17
-
-
Save erchenger/d2e0ee7dda3e3642eca8 to your computer and use it in GitHub Desktop.
How to merge two data sources with rxJava.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restObservable = giphyService.searchGiphy(getGiphyQueryMap("dog")).flatMap(new Func1<GiphySearch, Observable<GiphyGif>>() { | |
@Override | |
public Observable<GiphyGif> call(GiphySearch giphySearch) { | |
return Observable.from(giphySearch.data); | |
} | |
}).zipWith(namesService.getPeople().flatMap(new Func1<List<People>, Observable<Person>>() { | |
@Override | |
public Observable<Person> call(List<People> people) { | |
return Observable.from(people); | |
} | |
}), new Func2<GiphyGif, Person, GifAndData>() { | |
@Override | |
public GifAndData call(GiphyGif giphyGif, Person person) { | |
return new GifAndData(giphyGif.url, person.name); | |
} | |
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment