Skip to content

Instantly share code, notes, and snippets.

@Marchuck
Created June 24, 2016 17:50
Show Gist options
  • Select an option

  • Save Marchuck/6737c1c5e7cd1e22929ac60a53aa8630 to your computer and use it in GitHub Desktop.

Select an option

Save Marchuck/6737c1c5e7cd1e22929ac60a53aa8630 to your computer and use it in GitHub Desktop.
String[] getIds = new String[]{"id:0", "id:1", "id:2", "id:3"};
rx.Observable.just(getIds)
.flatMap(new Func1<String[], Observable<String>>() {
@Override
public Observable<String> call(String[] strings) {
//dla kazdego id odpytaj api
return Observable.from(strings);
}
}).flatMap(new Func1<String, Observable<Integer>>() {
@Override
public Observable<Integer> call(String osoba) {
//get na szczegóły osoby
return Observable.just(osoba.length());
}
}, new Func2<String, Integer, Boolean>() {
@Override
public Boolean call(String osoba, Integer szczegoly) {
//save to realm: osoba wraz z jej szczegółami
return true;
}
}).subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
//onNext
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
//onError
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment