-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make TimeoutId platform-specific type
- Loading branch information
Showing
4 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
10 changes: 6 additions & 4 deletions
10
reaktive/src/jsCommonMain/kotlin/com/badoo/reaktive/scheduler/JsFunctions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal expect fun jsSetTimeout(task: () -> Unit, delayMillis: Int): Any | ||
internal expect class TimeoutId | ||
|
||
internal expect fun jsSetInterval(task: () -> Unit, delayMillis: Int): Any | ||
internal expect fun jsSetTimeout(task: () -> Unit, delayMillis: Int): TimeoutId | ||
|
||
internal expect fun jsClearTimeout(id: Any) | ||
internal expect fun jsSetInterval(task: () -> Unit, delayMillis: Int): TimeoutId | ||
|
||
internal expect fun jsClearInterval(id: Any) | ||
internal expect fun jsClearTimeout(id: TimeoutId) | ||
|
||
internal expect fun jsClearInterval(id: TimeoutId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 24 additions & 4 deletions
28
reaktive/src/wasmJsMain/kotlin/com/badoo/reaktive/scheduler/JsFunctions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,35 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal actual fun jsSetTimeout(task: () -> Unit, delayMillis: Int): Any = | ||
internal actual class TimeoutId(val id: JsAny) | ||
|
||
internal actual fun jsSetTimeout(task: () -> Unit, delayMillis: Int): TimeoutId = | ||
TimeoutId(jsSetTimeoutInternal(task, delayMillis)) | ||
|
||
internal actual fun jsSetInterval(task: () -> Unit, delayMillis: Int): TimeoutId = | ||
TimeoutId(jsSetIntervalInternal(task, delayMillis)) | ||
|
||
internal actual fun jsClearTimeout(id: TimeoutId) { | ||
jsClearTimeoutInternal(id.id) | ||
} | ||
|
||
internal actual fun jsClearInterval(id: TimeoutId) { | ||
jsClearIntervalInternal(id.id) | ||
} | ||
|
||
@Suppress("UnusedPrivateMember") | ||
private fun jsSetTimeoutInternal(task: () -> Unit, delayMillis: Int): JsAny = | ||
js("setTimeout(task, delayMillis)") | ||
|
||
internal actual fun jsSetInterval(task: () -> Unit, delayMillis: Int): Any = | ||
@Suppress("UnusedPrivateMember") | ||
private fun jsSetIntervalInternal(task: () -> Unit, delayMillis: Int): JsAny = | ||
js("setInterval(task, delayMillis)") | ||
|
||
internal actual fun jsClearTimeout(id: Any) { | ||
@Suppress("UnusedPrivateMember") | ||
private fun jsClearTimeoutInternal(id: JsAny) { | ||
js("clearTimeout(id)") | ||
} | ||
|
||
internal actual fun jsClearInterval(id: Any) { | ||
@Suppress("UnusedPrivateMember") | ||
private fun jsClearIntervalInternal(id: JsAny) { | ||
js("clearInterval(id)") | ||
} |