Skip to content

Instantly share code, notes, and snippets.

import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
class Hoge
class Fuga
@ExperimentalCoroutinesApi
suspend fun hoge(): Hoge {
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
class InvocationRecorder0 {
inner class Arguments
inner class Verifier {
fun called() = count() >= 1
fun neverCalled() = count() <= 0
fun count() = arguments.size
}
val verifier = Verifier()
import androidx.annotation.VisibleForTesting
import io.reactivex.Observable
import io.reactivex.Single
class RxSingleHot {
private data class SharedObservable(
val id: Int,
val observable: Observable<*>
)
require 'googleauth/token_store'
class OnMemoryTokenStore < Google::Auth::TokenStore
def initialize()
@cache = {}
end
def load(id)
@cache[id]
end
def store(id, token)
import io.ktor.client.HttpClient
import io.ktor.client.features.HttpClientFeature
import io.ktor.client.response.HttpResponse
import io.ktor.client.response.HttpResponseContainer
import io.ktor.client.response.HttpResponsePipeline
import io.ktor.util.AttributeKey
internal class WrappedHttpResponseTransform {
companion object Feature : HttpClientFeature<Unit, WrappedHttpResponseTransform> {
import kotlinx.coroutines.CoroutineScope
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
/**
* To use test suspending function
* @param expected A conditions of expected exception. Default is null (unchecked)
* @param context coroutine context to use
* @param block testing body
*/
using System;
using System.Threading.Tasks;
class Program
{
static async ValueTask<int> HeavyTask(int value)
{
await Task.Delay(1000);
return value * value;
}
class Cancellable {
constructor() {
/**
* @private
* @type {!CancellationToken}
*/
this._token = new CancellationToken(this);
/**
* @private
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.broadcast
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlin.coroutines.CoroutineContext
class View(ui: CoroutineContext) {
private val presenter = Presenter(
ui = ui,