Last active
August 8, 2018 02:50
-
-
Save David-Hackro/9427aee78bec84f69daf44a313e7a17e to your computer and use it in GitHub Desktop.
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
//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