There are a few more .flatMap() variations that we can use. Recall the following block:
Observable.interval(0, 5, TimeUnit.SECONDS) .flatMap( i -> yahooService.yqlQuery(query, env) .toObservable() )
The .yqlQuery() call returns a Single type and thus cannot be used directly with .flatMap(), which expects to consume the Observable type. In this case, to work around that, we had to use the following to convert it to the Observable type:
However, there is a better way. Instead of using .flatMap(), we can use .flatMapSingle() to do the same thing:
Observable.interval(0, 5, TimeUnit.SECONDS) .flatMapSingle(i -> yahooService.yqlQuery(query, env))
.flatMapSingle() takes the Single type and automatically ...