-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MainExecutor abstract and extract platform-specific logic to rel…
…evant targets
- Loading branch information
Showing
6 changed files
with
69 additions
and
24 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
reaktive/src/jsCommonMain/kotlin/com/badoo/reaktive/scheduler/JsFunctions.kt
This file was deleted.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
reaktive/src/jsMain/kotlin/com/badoo/reaktive/scheduler/MainThreadExecutor.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,21 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
import com.badoo.reaktive.disposable.CompositeDisposable | ||
|
||
@Suppress("FunctionName") | ||
actual fun MainThreadExecutor(disposables: CompositeDisposable): Scheduler.Executor = | ||
object : MainScheduler.BaseExecutor<dynamic>(disposables) { | ||
override fun setTimeout(task: () -> Unit, delayMillis: Int): dynamic = | ||
jsSetTimeout(task, delayMillis) | ||
|
||
override fun setInterval(task: () -> Unit, delayMillis: Int): dynamic = | ||
jsSetInterval(task, delayMillis) | ||
|
||
override fun clearTimeout(id: dynamic) { | ||
jsClearTimeout(id) | ||
} | ||
|
||
override fun clearInterval(id: dynamic) { | ||
jsClearInterval(id) | ||
} | ||
} |
12 changes: 8 additions & 4 deletions
12
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,19 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
internal actual fun jsSetTimeout(task: () -> Unit, delayMillis: Int): Any = | ||
@Suppress("UnusedPrivateMember") | ||
internal fun jsSetTimeout(task: () -> Unit, delayMillis: Int): JsAny = | ||
js("setTimeout(task, delayMillis)") | ||
|
||
internal actual fun jsSetInterval(task: () -> Unit, delayMillis: Int): Any = | ||
@Suppress("UnusedPrivateMember") | ||
internal fun jsSetInterval(task: () -> Unit, delayMillis: Int): JsAny = | ||
js("setInterval(task, delayMillis)") | ||
|
||
internal actual fun jsClearTimeout(id: Any) { | ||
@Suppress("UnusedPrivateMember") | ||
internal fun jsClearTimeout(id: JsAny) { | ||
js("clearTimeout(id)") | ||
} | ||
|
||
internal actual fun jsClearInterval(id: Any) { | ||
@Suppress("UnusedPrivateMember") | ||
internal fun jsClearInterval(id: JsAny) { | ||
js("clearInterval(id)") | ||
} |
21 changes: 21 additions & 0 deletions
21
reaktive/src/wasmJsMain/kotlin/com/badoo/reaktive/scheduler/MainThreadExecutor.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,21 @@ | ||
package com.badoo.reaktive.scheduler | ||
|
||
import com.badoo.reaktive.disposable.CompositeDisposable | ||
|
||
@Suppress("FunctionName") | ||
actual fun MainThreadExecutor(disposables: CompositeDisposable): Scheduler.Executor = | ||
object : MainScheduler.BaseExecutor<JsAny>(disposables) { | ||
override fun setTimeout(task: () -> Unit, delayMillis: Int): JsAny = | ||
jsSetTimeout(task, delayMillis) | ||
|
||
override fun setInterval(task: () -> Unit, delayMillis: Int): JsAny = | ||
jsSetInterval(task, delayMillis) | ||
|
||
override fun clearTimeout(id: JsAny) { | ||
jsClearTimeout(id) | ||
} | ||
|
||
override fun clearInterval(id: JsAny) { | ||
jsClearInterval(id) | ||
} | ||
} |