To add to my previous question, here is my own implementation to achieve a loop that calls Func1.
Well, with some problem... so I am hoping someone can answer this for me as well, thanks.
...
return Observable.from(list)
.reduce(new Func2<String, String, String>() {
@Override
public String call(String arg0, String arg1) {
// (A)
return Observable.just(arg0)
.flatMap(new Func1<String, Observable<String>>() {
@Override
public Observable<String> call(String arg0) {
return Observable.just(arg0);
}
}); // (C)
// (B)
// return arg0 + arg1;
}
})
...
Each iteration for reduce(), you have to return String. Therefore, (B) works (without (A)).
What I am trying to do with (A) instead of (B) is to try to call other Func1 within reduce().
The problem is, I cannot return String after Func1, which is a requirement of reduce().
Is there such thing as convert Observable<String> to String?
What function can I append to (C) to get a String, so that reduce() can get that String?
Or, forget above all, how can I iterate a list, during which other Func1 can be called?
Thank you.
-uppsax