1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.coroutines 6 7 import kotlinx.coroutines.internal.* 8 9 internal actual abstract class CompletionHandlerBase : LinkedListNode() { 10 @JsName("invoke") invokenull11 actual abstract fun invoke(cause: Throwable?) 12 } 13 14 @Suppress("UnsafeCastFromDynamic") 15 internal actual inline val CompletionHandlerBase.asHandler: CompletionHandler get() = asDynamic() 16 17 internal actual abstract class CancelHandlerBase { 18 @JsName("invoke") 19 actual abstract fun invoke(cause: Throwable?) 20 } 21 22 @Suppress("UnsafeCastFromDynamic") 23 internal actual inline val CancelHandlerBase.asHandler: CompletionHandler get() = asDynamic() 24 invokeItnull25internal actual fun CompletionHandler.invokeIt(cause: Throwable?) { 26 when(jsTypeOf(this)) { 27 "function" -> invoke(cause) 28 else -> asDynamic().invoke(cause) 29 } 30 } 31