Created
December 3, 2018 10:30
-
-
Save anitaa1990/dc168b63a0a9839cf240e911a8bee0e9 to your computer and use it in GitHub Desktop.
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
/* | |
* Step 1: Create an observable that emits an integer | |
* from 1 to 5. Each item is squared by itself before it is | |
* emitted. | |
* */ | |
Observable<Integer> observable = Observable.range(1, 5) | |
.subscribeOn(Schedulers.io()) | |
.map(integer -> { | |
System.out.println(String.format("Squaring %d with itself", integer)); | |
return integer * integer; | |
}); | |
/* | |
* Step 2: We are subscribing two subscribers to the Observable. | |
* */ | |
observable.subscribe(s -> System.out.println("subscriber one: " + s)); | |
observable.subscribe(s -> System.out.println("subscriber two: " + s)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment