This file contains hidden or 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
| @file:OptIn(ExperimentalTime::class) | |
| import kotlinx.coroutines.* | |
| import kotlin.time.* | |
| suspend fun main() { | |
| coroutineScope { | |
| println("Launching tasks…") |
This file contains hidden or 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
| // Dependencies: | |
| // implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") | |
| // implementation("org.jetbrains.kotlinx:atomicfu:0.14.4") | |
| import kotlinx.atomicfu.* | |
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.channels.* | |
| import kotlinx.coroutines.selects.* | |
| import java.io.* | |
| import kotlin.coroutines.* |
This file contains hidden or 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
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.flow.* | |
| private val undefined = Any() | |
| internal fun <T> Iterable<Flow<T>>.combineLatest(): Flow<List<T>> = | |
| combineLatest { it } | |
This file contains hidden or 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
| import io.ktor.application.* | |
| import io.ktor.client.* | |
| import io.ktor.client.engine.cio.* | |
| import io.ktor.client.request.* | |
| import io.ktor.client.statement.* | |
| import io.ktor.http.* | |
| import io.ktor.response.* | |
| import io.ktor.routing.* | |
| import io.ktor.server.engine.* | |
| import io.ktor.server.netty.* |
This file contains hidden or 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
| import io.ktor.application.* | |
| import io.ktor.client.* | |
| import io.ktor.client.engine.* | |
| import io.ktor.client.engine.apache.* | |
| import io.ktor.client.engine.cio.* | |
| import io.ktor.client.engine.jetty.* | |
| import io.ktor.client.engine.okhttp.* | |
| import io.ktor.client.request.* | |
| import io.ktor.client.statement.* | |
| import io.ktor.http.* |
This file contains hidden or 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
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.flow.* | |
| /* Output: | |
| cache collected: initial | |
| flow1 (collector 1) collected: initial | |
| flow1 (collector 2) collected: initial | |
| flow2 (collector 1) collected: initial |
This file contains hidden or 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
| /* Output | |
| Collecting 2 elements… | |
| upstream -> hot | |
| emit: 0 | |
| resumed | |
| collect: 0 | |
| Expensive work on 0 (isPaused = false)… | |
| Expensive work on 0 (isPaused = false)… | |
| Expensive work on 0 (isPaused = false)… |
This file contains hidden or 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
| @JsName("require") | |
| external fun asset(path: String): String | |
| // in a React builder | |
| img(src = asset("image.png")) {} |
This file contains hidden or 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
| public external interface StringBuilder | |
| public inline fun StringBuilder.append(value: Any) { | |
| append("$value") | |
| } | |
| public inline fun StringBuilder.append(string: String) { | |
| if (string != "") |