Guest User

Untitled

a guest
Aug 7th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. //Service GetStudent
  2. public Observable<ResponseService> GetStudent(String id_student) {
  3. return retrofit.create(Service.class).GetStudent(id_student);
  4. }
  5.  
  6. //Ids of Students
  7. String id_student1= "asdfghjkl11";
  8. String id_student2= "qwertyuio88";
  9.  
  10. //creation of observables with the service
  11. Observable<ResponseService> student1 = GetStudent(id_student1).subscribeOn(Schedulers.io());
  12. Observable<ResponseService> student2 = GetStudent(id_student2).subscribeOn(Schedulers.io());
  13.  
  14.  
  15. Observable<List<ResponseService>> zip = Observable.zip(student1, student2, (d, r) -> {
  16. return Arrays.asList(d, r);
  17. });
  18.  
  19. zip
  20. .observeOn(AndroidSchedulers.mainThread())
  21. .subscribe(new Subscriber<List<ResponseService>>() {
  22. @Override
  23. public void onCompleted() {
  24.  
  25. }
  26.  
  27. @Override
  28. public void onError(Throwable e) {
  29.  
  30. }
  31.  
  32. @Override
  33. public void onNext(List<ResponseService> ResponseServices) {
  34. //Result of list request :D yea!
  35. }
  36. });
Add Comment
Please, Sign In to add comment