Skip to content

Instantly share code, notes, and snippets.

@David-Hackro
Last active August 8, 2018 02:50
Show Gist options
  • Save David-Hackro/9427aee78bec84f69daf44a313e7a17e to your computer and use it in GitHub Desktop.
Save David-Hackro/9427aee78bec84f69daf44a313e7a17e to your computer and use it in GitHub Desktop.
//Service GetStudent
public Observable<ResponseService> GetStudent(String id_student) {
return retrofit.create(Service.class).GetStudent(id_student);
}
//Ids of Students
String id_student1= "asdfghjkl11";
String id_student2= "qwertyuio88";
//creation of observables with the service
Observable<ResponseService> student1 = GetStudent(id_student1).subscribeOn(Schedulers.io());
Observable<ResponseService> student2 = GetStudent(id_student2).subscribeOn(Schedulers.io());
Observable<List<ResponseService>> zip = Observable.zip(student1, student2, (d, r) -> {
return Arrays.asList(d, r);
});
zip
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<ResponseService>>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(List<ResponseService> ResponseServices) {
//Result of list request :D yea!
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment