Reputation: 39
I wrote a method to print the output from flatMap (Pseudo code):
Observable.just(...).repeat()
.flatMap( return Observable.just([double]))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Double>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
tvConfidence.setText(e.getMessage());
}
@Override
public void onNext(Double aDouble) {
tvConfidence.setText("Confidence :" + aDouble);
}
});
When I run these code, it works a few seconds but after a few seconds, it would not run onto the onNext
method again. I don't know why, because I debug the code, it will run the Observable.just(double)
, and the value always changed but it would not execute the code setText
to refresh the textView
.
Upvotes: 1
Views: 351
Reputation: 69997
My guess is that due to that particular flatMap
overload, you eventually start to accumulate a lot of just
because flatMap
is unbounded-in. Try with flatMap(f, 1)
to limit the concurrency level.
Upvotes: 1