Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // emit an observable every time interval
- Observable<Long> intervalObservable = Observable
- .interval(1, TimeUnit.SECONDS)
- .subscribeOn(Schedulers.io())
- .takeWhile(new Predicate<Long>() { // stop the process if more than 5 seconds passes
- @Override
- public boolean test(Long aLong) throws Exception {
- return aLong <= 5;
- }
- })
- .observeOn(AndroidSchedulers.mainThread());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement