java - Restart observable based on its emitted values with RxJava -


i have observable want emit integer values, if 1 of emitted values negative, want observable emit values again 1 second delay between emissions until there's no negative values.

i found answer repeat/resubscribe observable condition based on emitted item(s) , don't because uses recursion may slow device down (depending on how many attempts it'd take proper results).

is there other (proper) way of doing that? don't know how set delay each emission except first one.

here's have now:

getobservable().subscribe(valuelist -> {         (integer value : valuelist) {             log.d("tag", "value: " + value);         }     });  private observable<list<integer>> getobservable() {     return observable.fromcallable(() -> {         list<integer> list = new arraylist<>();         random random = new random();         (int = 0; < 10; i++) {             list.add(random.nextint(12) - 1);         }         return list;     }).flatmap(valuelist -> {         (int = 0; < valuelist.size(); i++) {             if (valuelist.get(i) < 0) {                 log.d("tag", "negative value = " + valuelist.get(i) + ", index = " + i);                 return getobservable().delay(1, timeunit.seconds);;             }         }         return observable.just(valuelist);     }); } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -