JS: implement new coroutine convention

This commit is contained in:
Alexey Andreev
2016-12-14 19:38:00 +03:00
committed by Stanislav Erokhin
parent 9fd1ac72a9
commit e2d969d8b0
20 changed files with 353 additions and 315 deletions
@@ -17,10 +17,10 @@ class Controller {
}
}
fun builder(coroutine c: () -> String): String {
fun builder(c: suspend Controller.() -> String): String {
val controller = Controller()
c.startCoroutine(handleResult {
controller.result += "return($value);"
c.startCoroutine(controller, handleResultContinuation {
controller.result += "return($it);"
})
return controller.result
}
@@ -13,7 +13,7 @@ class Controller {
}
}
// MODULE: main(controller)
// MODULE: main(controller, support)
// FILE: main.kt
import lib.*
import kotlin.coroutines.*
-2
View File
@@ -1,9 +1,7 @@
// IGNORE_BACKEND: JS
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
suspend fun suspendHere(): String = suspendWithCurrentContinuation { x ->
x.resume("OK")
SUSPENDED