-
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
7 changed files
with
45 additions
and
18 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
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,9 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal expect fun jsSetTimeout(task: () -> Unit, delayMillis: Int): Any | ||
internal expect fun jsSetTimeout(task: () -> Unit, delayMillis: Int): TimeoutId | ||
|
||
internal expect fun jsSetInterval(task: () -> Unit, delayMillis: Int): Any | ||
internal expect fun jsSetInterval(task: () -> Unit, delayMillis: Int): TimeoutId | ||
|
||
internal expect fun jsClearTimeout(id: Any) | ||
internal expect fun jsClearTimeout(id: TimeoutId) | ||
|
||
internal expect fun jsClearInterval(id: Any) | ||
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
3 changes: 3 additions & 0 deletions
3
reaktive/src/jsCommonMain/kotlin/com/badoo/reaktive/scheduler/TimeoutId.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal expect class 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
3 changes: 3 additions & 0 deletions
3
reaktive/src/jsMain/kotlin/com/badoo/reaktive/scheduler/TimeoutId.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal actual class TimeoutId(val id: dynamic) |
26 changes: 22 additions & 4 deletions
26
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,33 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal actual fun jsSetTimeout(task: () -> Unit, delayMillis: Int): Any = | ||
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)") | ||
} |
3 changes: 3 additions & 0 deletions
3
reaktive/src/wasmJsMain/kotlin/com/badoo/reaktive/scheduler/TimeoutId.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal actual class TimeoutId(val id: JsAny) |