Last active
January 3, 2018 13:56
-
-
Save radityagumay/125fdaaa7935d1fb3eca7aff5060facc to your computer and use it in GitHub Desktop.
RxCompose
This file contains 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
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