mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-04 23:59:29 +00:00
less annotations to god of lessannotations
This commit is contained in:
@@ -3,8 +3,10 @@ package dev.inmo.micro_utils.coroutines
|
||||
import kotlinx.coroutines.channels.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlin.js.JsExport
|
||||
import kotlin.js.JsName
|
||||
|
||||
@JsExport
|
||||
@JsName("BroadcastFlowFactory")
|
||||
@Suppress("FunctionName")
|
||||
fun <T> BroadcastFlow(
|
||||
internalChannelSize: Int = Channel.BUFFERED
|
||||
|
@@ -5,6 +5,7 @@ import kotlinx.coroutines.channels.BroadcastChannel
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlin.js.JsExport
|
||||
import kotlin.js.JsName
|
||||
|
||||
@JsExport
|
||||
class BroadcastStateFlow<T> internal constructor(
|
||||
@@ -25,6 +26,7 @@ fun <T> BroadcastChannel<T>.asStateFlow(value: T, scope: CoroutineScope): StateF
|
||||
}
|
||||
|
||||
@JsExport
|
||||
@JsName("nullableAsStateFlow")
|
||||
fun <T> BroadcastChannel<T?>.asStateFlow(scope: CoroutineScope): StateFlow<T?> = asStateFlow(null, scope)
|
||||
|
||||
@JsExport
|
||||
@@ -35,5 +37,6 @@ fun <T> broadcastStateFlow(initial: T, scope: CoroutineScope, channelSize: Int =
|
||||
}
|
||||
|
||||
@JsExport
|
||||
@JsName("nullableBroadcastStateFlow")
|
||||
fun <T> broadcastStateFlow(scope: CoroutineScope, channelSize: Int = Channel.BUFFERED) = broadcastStateFlow<T?>(null, scope, channelSize)
|
||||
|
||||
|
@@ -2,8 +2,6 @@ package dev.inmo.micro_utils.coroutines
|
||||
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlin.js.JsExport
|
||||
|
||||
@JsExport
|
||||
val <T> T.asDeferred: Deferred<T>
|
||||
get() = CompletableDeferred(this)
|
||||
|
@@ -6,7 +6,6 @@ import kotlin.js.JsExport
|
||||
/**
|
||||
* Call this method in case you need to do something in common thread (like reading of file in JVM)
|
||||
*/
|
||||
@JsExport
|
||||
suspend fun <T> doOutsideOfCoroutine(block: () -> T): T = suspendCoroutine {
|
||||
try {
|
||||
it.resume(block())
|
||||
|
@@ -12,7 +12,6 @@ typealias ExceptionHandler<T> = suspend (Throwable) -> T
|
||||
* @param [onException] Will be called when happen exception inside of [block]. By default will throw exception - this
|
||||
* exception will be available for catching
|
||||
*/
|
||||
@JsExport
|
||||
suspend inline fun <T> safely(
|
||||
noinline onException: ExceptionHandler<T> = { throw it },
|
||||
noinline block: suspend CoroutineScope.() -> T
|
||||
|
Reference in New Issue
Block a user