Skip to content

Instantly share code, notes, and snippets.

@radityagumay
Last active January 3, 2018 13:56
Show Gist options
  • Save radityagumay/125fdaaa7935d1fb3eca7aff5060facc to your computer and use it in GitHub Desktop.
Save radityagumay/125fdaaa7935d1fb3eca7aff5060facc to your computer and use it in GitHub Desktop.
RxCompose
override fun doSomeWork() {
val d = Observable.create(ObservableOnSubscribe<String> { e ->
for (i in 0 until 10) {
val number = Math.pow(Random().nextInt(100).toDouble(), Random().nextInt(100).toDouble())
e.onNext(number.toString())
}
e.onComplete()
}).compose(loading { isShow ->
if (isShow) {
view.showLoading()
} else {
view.hideLoading()
}
}).compose(before { before()
}).compose(after { after()
}).compose(observableIo())
.subscribe { number ->
view.showCompleteWork(number)
}
disposable.add(d)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment