Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KarthicRaj/3be144a2ee2b765318ba to your computer and use it in GitHub Desktop.
Save KarthicRaj/3be144a2ee2b765318ba to your computer and use it in GitHub Desktop.
/**
* 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