| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Android RxJava, how to start, stop, reset Observable.interval programmatically on run time!
In this sample app, we are creating a class that is triggering an event each n time, in addition we have added useful methods to the class, that will allow as to use it smoothly.
to understand this samble, you should have a knowledge of:
This is a Samble app that is connecting to Nasa rest API service to get data and display it in a list view. This App aims to present of how to build a clean code using Dagger 2 and MVP structure.
subscription = Observable.interval(period, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
onTickListener.onTick();
});As you see, Observable.interval takes two parameters
Take care the ObserveOn will not run on UI thread if you did not pass AndroidSchedulers.mainThread
observeOn(AndroidSchedulers.mainThread())
and on each tick, the observer will call: subscribe(aLong -> { //do what ever you want here... });
if (subscription != null && !subscription.isDisposed()) {
subscription.dispose();
}Check out amjadomari awesome open source projects here
Just make pull request. You are in!
| Back | FazBrowse Home | New Git URL |