Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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!
- }
- });
Add Comment
Please, Sign In to add comment