Created
October 1, 2018 15:44
-
-
Save CoderJava/8239d166e19a089709f940e9ea2e21b6 to your computer and use it in GitHub Desktop.
Operator timer RxJava
This file contains hidden or 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
| public class RxOperatorTimer { | |
| public static void main(String[] args) throws InterruptedException { | |
| CountDownLatch countDownLatch = new CountDownLatch(1); | |
| Observable.timer(1000 * 2, TimeUnit.MILLISECONDS) | |
| .subscribe(new Observer<Long>() { | |
| @Override | |
| public void onSubscribe(Disposable d) { | |
| System.out.println("onSubscribe"); | |
| } | |
| @Override | |
| public void onNext(Long count) { | |
| System.out.println("onNext " + count); | |
| } | |
| @Override | |
| public void onError(Throwable e) { | |
| System.out.println("onError"); | |
| } | |
| @Override | |
| public void onComplete() { | |
| System.out.println("onComplete"); | |
| countDownLatch.countDown(); | |
| } | |
| }); | |
| countDownLatch.await(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment