O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Regular updates

It wouldn't be a proper financial stocks monitor if it was unable to get updates automatically.

To get updates automatically from the Yahoo Finance data, we will use a polling mechanism. It means that the app will check for updates by itself at regular intervals.

We can do that by changing the given part:

yahooService.yqlQuery(query, env)        .toObservable()

We can do so by prepending Observable.interval() to look like this:

Observable.interval(0, 5, TimeUnit.SECONDS)        .flatMap(                i -> yahooService.yqlQuery(query, env)                        .toObservable()        )

The following code creates an observable that emits an integer sequence at the specified interval:

Observable.interval(0, 5, TimeUnit.SECONDS)

In this case, it will be every 5 seconds. The first ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required