diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index db989cb2..afc0232f 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -51,8 +51,8 @@ object Dependencies { } object Asynchrony { - const val REACTIVE_EXTENSIONS = "com.badoo.reaktive:reaktive:1.3.0" - const val REACTIVE_EXTENSIONS_COROUTINE_INTEROP = "com.badoo.reaktive:coroutines-interop:1.3.0" + const val REACTIVE_EXTENSIONS = "com.badoo.reaktive:reaktive:2.0.0" + const val REACTIVE_EXTENSIONS_COROUTINE_INTEROP = "com.badoo.reaktive:coroutines-interop:2.0.0" } object Commons { diff --git a/lib-kmm-foundation/src/commonMain/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSource.kt b/lib-kmm-foundation/src/commonMain/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSource.kt index 2e7aa455..41dc0e9b 100644 --- a/lib-kmm-foundation/src/commonMain/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSource.kt +++ b/lib-kmm-foundation/src/commonMain/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSource.kt @@ -21,20 +21,22 @@ import com.badoo.reaktive.observable.Observable import com.badoo.reaktive.observable.debounce import com.badoo.reaktive.scheduler.Scheduler import com.badoo.reaktive.scheduler.computationScheduler +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds class DebouncingEventSource( - private val timeoutMillis: Long, + private val timeoutMillis: Duration, private val scheduler: Scheduler, private val origin: EventSource ) : EventSource { - constructor(origin: EventSource) : this(DEFAULT_TIMEOUT_MILLIS, computationScheduler, origin) + constructor(origin: EventSource) : this(DEFAULT_TIMEOUT, computationScheduler, origin) override fun events(): Observable { return origin.events().debounce(timeoutMillis, scheduler) } companion object { - private const val DEFAULT_TIMEOUT_MILLIS = 300L + private val DEFAULT_TIMEOUT = 300L.milliseconds } } diff --git a/lib-kmm-foundation/src/commonTest/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSourceTest.kt b/lib-kmm-foundation/src/commonTest/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSourceTest.kt index 55d6d7ff..0151d2d9 100644 --- a/lib-kmm-foundation/src/commonTest/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSourceTest.kt +++ b/lib-kmm-foundation/src/commonTest/kotlin/com/hadisatrio/libs/kotlin/foundation/event/DebouncingEventSourceTest.kt @@ -24,15 +24,16 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlin.test.Test +import kotlin.time.Duration.Companion.milliseconds class DebouncingEventSourceTest { @Test fun `Debounces the given origin`() { - val timeoutMillis = 100L + val timeout = 100L.milliseconds val scheduler = mockk(relaxed = true) val origin = mockk(relaxed = true) - val source = DebouncingEventSource(timeoutMillis, scheduler, origin) + val source = DebouncingEventSource(timeout, scheduler, origin) every { origin.events() } returns PublishSubject() source.events().subscribe { }