diff --git a/build.gradle b/build.gradle index e588f16..a495bdc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.0-beta-38' - ext.kotlin_coroutines_version = '0.7-beta' + ext.kotlin_version = '1.1.4-3' + ext.kotlin_coroutines_version = '0.18' repositories { jcenter() maven { diff --git a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt index cc637db..7fe196f 100644 --- a/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt +++ b/coroutines-android/src/main/kotlin/ru/gildor/coroutines/android/MainThreadDispatcher.kt @@ -59,7 +59,7 @@ object MainThread : CoroutineDispatcher(), Delay { */ handler.postDelayed(runnable, unit.toMillis(time)) - continuation.onCompletion { handler.removeCallbacks(runnable) } + continuation.invokeOnCompletion { handler.removeCallbacks(runnable) } } } @@ -73,7 +73,7 @@ fun CoroutineLifecycle.mainAsync( context: CoroutineContext? = null, // Using EmptyCoroutineContext by default here will safe an `if` below block: suspend CoroutineScope.() -> Unit ): Job { - if (isEventSupported(cancelEvent)) { + if (!isEventSupported(cancelEvent)) { throw IllegalStateException("Cancel event $cancelEvent doesn't supported by CoroutineLifecycle $this") } val job = launch(if (context == null) MainThread else context + MainThread) { @@ -82,7 +82,7 @@ fun CoroutineLifecycle.mainAsync( val listener: () -> Unit = { job.cancel() } - job.onCompletion { removeListener(listener) } + job.invokeOnCompletion { removeListener(listener) } addListener(Destroy, listener) return job } diff --git a/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt b/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt index 457b5ee..abda47f 100644 --- a/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt +++ b/coroutines-retrofit/src/main/kotlin/ru/gildor/coroutines/retrofit/CallAwait.kt @@ -28,7 +28,6 @@ suspend fun Call.await(): T { continuation.resumeWithException(t) } }) - registerOnCompletion(continuation) } } @@ -58,7 +57,7 @@ suspend fun Call.awaitResult(): Result { } private fun Call<*>.registerOnCompletion(continuation: CancellableContinuation<*>) { - continuation.onCompletion { + continuation.invokeOnCompletion { if (continuation.isCancelled) try { cancel()