Skip to content

Instantly share code, notes, and snippets.

Avatar

Keita Kagurazaka k-kagurazaka

View GitHub Profile
@k-kagurazaka
k-kagurazaka / Main.kt
Last active Dec 20, 2017
RxCommand with double context extension pattern
View Main.kt
interface HasDisposables {
fun Disposable.autoDispose()
fun dispose()
companion object {
operator fun invoke(): HasDisposables = object : HasDisposables {
private val disposables = CompositeDisposable()
@k-kagurazaka
k-kagurazaka / DebounceTest.kt
Created Dec 1, 2017
RxJava debounce like operator implementation for kotlin coroutine
View DebounceTest.kt
launch(UI) {
editText.onTextChanged()
.debounce(1, TimeUnit.SECONDS)
.consumeEach {
Log.d("DebounceTest", "value: $it")
}
}
}
fun EditText.onTextChanged(): ReceiveChannel<String> =