Skip to content

Instantly share code, notes, and snippets.

@smhdk
Last active November 25, 2018 18:52
Show Gist options
  • Save smhdk/757140e577a65e44b109c3c757386d75 to your computer and use it in GitHub Desktop.
Save smhdk/757140e577a65e44b109c3c757386d75 to your computer and use it in GitHub Desktop.
Simple RxJava Example
//Observable
val getObservable = Observable.just("X", "Y", "Z")
//Observer
val getObserver = object : Observer<String> {
override fun onComplete() {
println("onComplete")
}
override fun onSubscribe(d: Disposable) {
println("onSubscribe")
}
override fun onNext(t: String) {
println("onNext: $t")
}
override fun onError(e: Throwable) {
println("onError")
}
}
//Subscription
getObservable
.subscribe(getObserver)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment