Forked from benjchristensen/simpleRxComposition.groovy
Last active
August 29, 2015 14:07
-
-
Save KarthicRaj/3be144a2ee2b765318ba 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
/** | |
* Asynchronously calls 'customObservableNonBlocking' and defines | |
* a chain of operators to apply to the callback sequence. | |
*/ | |
def simpleComposition() { | |
// fetch an asynchronous Observable<String> | |
// that emits 75 Strings of 'anotherValue_#' | |
customObservableNonBlocking() | |
// skip the first 10 | |
.skip(10) | |
// take the next 5 | |
.take(5) | |
// transform each String with the provided function | |
.map({ stringValue -> return stringValue + "_transformed"}) | |
// subscribe to the sequence and print each transformed String | |
.subscribe({ println "onNext => " + it}) | |
} | |
// output | |
onNext => anotherValue_10_transformed | |
onNext => anotherValue_11_transformed | |
onNext => anotherValue_12_transformed | |
onNext => anotherValue_13_transformed | |
onNext => anotherValue_14_transformed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment