Created
March 27, 2019 06:01
-
-
Save if6was9/e912e7fa2feecf0ff0e7e672df84d1c1 to your computer and use it in GitHub Desktop.
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
| ObservableOnSubscribe<String> observableOnSubscribe = new ObservableOnSubscribe<String>() { | |
| @Override | |
| public void subscribe(ObservableEmitter<String> emitter) throws Exception { | |
| // This will be called when subscribe() is called | |
| // At this point | |
| System.out.println(Thread.currentThread()+": ObservableOnSubscribe.subscribe() called"); | |
| ImmutableList.of("one","two","three").forEach(it->{ | |
| System.out.println(Thread.currentThread()+": emitter.onNext("+it+") called"); | |
| emitter.onNext(it); | |
| }); | |
| System.out.println(Thread.currentThread()+": emitter.onComplete() called"); | |
| emitter.onComplete(); | |
| System.out.println(Thread.currentThread()+": leaving subscribe()"); | |
| } | |
| }; | |
| System.out.println(Thread.currentThread()+": calling Observable.create()..."); | |
| Observable obs = Observable.create(observableOnSubscribe); | |
| System.out.println(Thread.currentThread()+": Observable.create() complete"); | |
| obs.observeOn(Schedulers.io()).subscribe(it->{ | |
| System.out.println(Thread.currentThread()+": received "+it); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment