Created
February 2, 2021 15:48
-
-
Save zinoviy23/c929fdf19d1556860625ef1111d4e61c to your computer and use it in GitHub Desktop.
Example of `doOnNext` on simple Reactive Stream
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
import io.reactivex.rxjava3.core.*; | |
public class Main { | |
public static void main(String[] args) throws InterruptedException { | |
Flowable.fromArray(1, 2, 3, 4, 5) | |
.doOnNext((i) -> System.out.println("1: " + i)) | |
.map(i -> i + 1) | |
.doOnNext((i) -> System.out.println("2: " + i)) | |
.filter(i -> i % 2 != 0) | |
.doOnNext((i) -> System.out.println("3: " + i)) | |
.map(Integer::toBinaryString) | |
.doOnNext(i -> System.out.println("4: " + i)) | |
.ignoreElements() | |
.blockingAwait(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output with comments: