Last active
November 4, 2020 23:22
-
-
Save maiconhellmann/3d84b4f5220af375aefae68d483cc8d3 to your computer and use it in GitHub Desktop.
Timer task in RxJava kotlin/java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val subscription = Observable.interval(0, 5, TimeUnit.SECONDS) | |
.timeInterval() | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribeOn(Schedulers.io()) | |
.subscribe { | |
//TODO | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disposable timerTaskSubscription = Observable.interval(0, 30, TimeUnit.SECONDS) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribeOn(Schedulers.io()) | |
.subscribe(new Consumer<Long>() { | |
@Override | |
public void accept(Long aLong) throws Exception { | |
//TODO onNext | |
} | |
}, | |
new Consumer<Throwable>() { | |
@Override | |
public void accept(Throwable throwable) throws Exception { | |
//TODO onError | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment