All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.com.zegreatrob.react.dataloader.UseScope.kt Maven / Gradle / Ivy

package com.zegreatrob.react.dataloader

import kotlinx.coroutines.*
import react.RCleanup
import react.useEffectWithCleanup
import react.useState

fun useScope(coroutineName: String): CoroutineScope {
    val (scope) = useState { MainScope() + CoroutineName(coroutineName) }
    val cleanup: RCleanup = { scope.cancel() }
    useEffectWithCleanup(dependencies = emptyList()) { cleanup }
    return scope
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy