Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to merge two data sources with rxJava.
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
You can’t perform that action at this time.