Say I have a function that accepts Stringand longand returns a Single<String>.
Single<String> stringAddition(String someString, long value) {
return Single.just(someString + Long.toString(value));
}
Now i have this Observable...
Observable.interval(1, SECONDS)
.scan("", (cumulativeString, item) -> {
// Need to return the result of stringAddition(cummulativeString, item)
});
I don’t understand how to do this. Scanning requires me to return String, but I would like to use a method that returns Single<String>. It seems to me that I need something that can combine behavior, both scan, and flatMap. Is there any RxJava2 magic that can help me?
source
share