Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // emit an observable every time interval
  2. Observable<Long> intervalObservable = Observable
  3. .interval(1, TimeUnit.SECONDS)
  4. .subscribeOn(Schedulers.io())
  5. .takeWhile(new Predicate<Long>() { // stop the process if more than 5 seconds passes
  6. @Override
  7. public boolean test(Long aLong) throws Exception {
  8. return aLong <= 5;
  9. }
  10. })
  11. .observeOn(AndroidSchedulers.mainThread());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement