1
1
package kotlinx.coroutines
2
2
3
- import org.w3c.dom.Window
4
3
import kotlin.js.*
5
4
6
- public actual typealias W3CWindow = Window
5
+ public actual abstract external class W3CWindow {
6
+ public fun clearTimeout (handle : Int )
7
+ }
7
8
8
9
internal actual fun w3cSetTimeout (window : W3CWindow , handler : () -> Unit , timeout : Int ): Int =
9
10
setTimeout(window, handler, timeout)
@@ -40,7 +41,7 @@ internal class NodeDispatcher(private val process: JsProcess) : SetTimeoutBasedD
40
41
}
41
42
42
43
@Suppress(" UNUSED_PARAMETER" )
43
- private fun subscribeToWindowMessages (window : Window , process : () -> Unit ): Unit = js(""" {
44
+ private fun subscribeToWindowMessages (window : W3CWindow , process : () -> Unit ): Unit = js(""" {
44
45
const handler = (event) => {
45
46
if (event.source == window && event.data == 'dispatchCoroutine') {
46
47
event.stopPropagation();
@@ -51,7 +52,7 @@ private fun subscribeToWindowMessages(window: Window, process: () -> Unit): Unit
51
52
}""" )
52
53
53
54
@Suppress(" UNUSED_PARAMETER" )
54
- private fun createRescheduleMessagePoster (window : Window ): () -> Unit =
55
+ private fun createRescheduleMessagePoster (window : W3CWindow ): () -> Unit =
55
56
js(" () => window.postMessage('dispatchCoroutine', '*')" )
56
57
57
58
@Suppress(" UNUSED_PARAMETER" )
@@ -84,5 +85,5 @@ private fun clearTimeout(handle: Int): Unit =
84
85
js(" { if (typeof clearTimeout !== 'undefined') clearTimeout(handle); }" )
85
86
86
87
@Suppress(" UNUSED_PARAMETER" )
87
- private fun setTimeout (window : Window , handler : () -> Unit , timeout : Int ): Int =
88
+ private fun setTimeout (window : W3CWindow , handler : () -> Unit , timeout : Int ): Int =
88
89
js(" window.setTimeout(handler, timeout)" )
0 commit comments