Created
June 11, 2020 08:31
-
-
Save MathiasSeguy-Android2EE/343dbf4fe3bc380bc4507c39b88a8ad7 to your computer and use it in GitHub Desktop.
Markdium-Chapter 9: Observable's action operators
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
| /** | |
| * Using the observableSrc we use doOnEach to understand its behavior | |
| */ | |
| public static Observable getObservableDoOnEach() { | |
| return observableSrc.doOnEach(it -> | |
| { | |
| System.out.print("onEach is " + it+" :"); | |
| if(it.isOnNext()) { | |
| System.out.println("isOnNext = " + it.isOnNext() +" and getValue = " + it.getValue()); | |
| }else if(it.isOnError()) { | |
| System.out.println("isOnError = " + it.isOnNext() +" and getError = " + it.getError()); | |
| }else { | |
| System.out.println("isOnComplete = " + it.isOnComplete()+" no value associated"); | |
| } | |
| }); | |
| } | |
| /** | |
| * OutPut result: | |
| * onEach is OnNextNotification[Monday] :isOnNext = true and getValue = Monday | |
| * onEach is OnNextNotification[Tuesday] :isOnNext = true and getValue = Tuesday | |
| * onEach is OnNextNotification[Wednesday] :isOnNext = true and getValue = Wednesday | |
| * onEach is OnNextNotification[Thursday] :isOnNext = true and getValue = Thursday | |
| * onEach is OnNextNotification[Friday] :isOnNext = true and getValue = Friday | |
| * onEach is OnNextNotification[Saturday] :isOnNext = true and getValue = Saturday | |
| * onEach is OnNextNotification[Sunday] :isOnNext = true and getValue = Sunday | |
| * onEach is OnCompleteNotification :isOnComplete = true no value associated | |
| */ | |
| @Test | |
| public void testDoOnEach() { | |
| Answer9_ObservableActions.getObservableDoOnEach() | |
| .subscribe(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment