Package dev.inmo.micro_utils.coroutines

Types

AccumulatorFlow
Link copied to clipboard
class AccumulatorFlow<T>(sourceDataFlow: Flow<T>, scope: CoroutineScope) : AbstractFlow<T>

This Flow will have behaviour very similar to SharedFlow, but there are several differences:

class AccumulatorFlow<T>(sourceDataFlow: Flow<T>, scope: CoroutineScope) : AbstractFlow<T>

This Flow will have behaviour very similar to SharedFlow, but there are several differences:

class AccumulatorFlow<T>(sourceDataFlow: Flow<T>, scope: CoroutineScope) : AbstractFlow<T>

This Flow will have behaviour very similar to SharedFlow, but there are several differences:

ActorAction
Link copied to clipboard
interface ActorAction<T>
interface ActorAction<T>
interface ActorAction<T>
ContextSafelyExceptionHandler
Link copied to clipboard
class ContextSafelyExceptionHandler(val handler: ExceptionHandler<Unit>) : CoroutineContext.Element

ExceptionHandler wrapper which was created to make possible to use handler across all coroutines calls

class ContextSafelyExceptionHandler(val handler: ExceptionHandler<Unit>) : CoroutineContext.Element

ExceptionHandler wrapper which was created to make possible to use handler across all coroutines calls

class ContextSafelyExceptionHandler(val handler: ExceptionHandler<Unit>) : CoroutineContext.Element

ExceptionHandler wrapper which was created to make possible to use handler across all coroutines calls

ContextSafelyExceptionHandlerKey
Link copied to clipboard

This key can (and will) be used to get ContextSafelyExceptionHandler from coroutineContext of suspend functions and in ContextSafelyExceptionHandler for defining of its CoroutineContext.Element.key

This key can (and will) be used to get ContextSafelyExceptionHandler from coroutineContext of suspend functions and in ContextSafelyExceptionHandler for defining of its CoroutineContext.Element.key

This key can (and will) be used to get ContextSafelyExceptionHandler from coroutineContext of suspend functions and in ContextSafelyExceptionHandler for defining of its CoroutineContext.Element.key

DeferredAction
Link copied to clipboard
class DeferredAction<T, O>(val deferred: Deferred<T>, val callback: suspend (T) -> O)
class DeferredAction<T, O>(val deferred: Deferred<T>, val callback: suspend (T) -> O)
class DeferredAction<T, O>(val deferred: Deferred<T>, val callback: suspend (T) -> O)
DoWithFirstBuilder
Link copied to clipboard
class DoWithFirstBuilder<T>(scope: CoroutineScope)
class DoWithFirstBuilder<T>(scope: CoroutineScope)
class DoWithFirstBuilder<T>(scope: CoroutineScope)
ExceptionHandler
Link copied to clipboard
typealias ExceptionHandler<T> = suspend (Throwable) -> T
typealias ExceptionHandler<T> = suspend (Throwable) -> T
typealias ExceptionHandler<T> = suspend (Throwable) -> T

Functions

accumulatorFlow
Link copied to clipboard
fun <T> Channel<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this with receiveAsFlow to get

fun <T> Flow<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this as base Flow

fun <T> Channel<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this with receiveAsFlow to get

fun <T> Flow<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this as base Flow

fun <T> Channel<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this with receiveAsFlow to get

fun <T> Flow<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this as base Flow

actor
Link copied to clipboard
fun <T> CoroutineScope.actor(channelCapacity: Int = Channel.UNLIMITED, block: suspend (T) -> Unit): Channel<T>
fun <T> CoroutineScope.actor(channelCapacity: Int = Channel.UNLIMITED, block: suspend (T) -> Unit): Channel<T>
fun <T> CoroutineScope.actor(channelCapacity: Int = Channel.UNLIMITED, block: suspend (T) -> Unit): Channel<T>
actorAsync
Link copied to clipboard
fun <T> CoroutineScope.actorAsync(    channelCapacity: Int = Channel.UNLIMITED,     markerFactory: suspend (T) -> Any? = { null },     block: suspend (T) -> Unit): Channel<T>
fun <T> CoroutineScope.actorAsync(    channelCapacity: Int = Channel.UNLIMITED,     markerFactory: suspend (T) -> Any? = { null },     block: suspend (T) -> Unit): Channel<T>
fun <T> CoroutineScope.actorAsync(    channelCapacity: Int = Channel.UNLIMITED,     markerFactory: suspend (T) -> Any? = { null },     block: suspend (T) -> Unit): Channel<T>
asyncSafely
Link copied to clipboard
inline fun <T> CoroutineScope.asyncSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> T): Deferred<T>
inline fun <T> CoroutineScope.asyncSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> T): Deferred<T>
inline fun <T> CoroutineScope.asyncSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> T): Deferred<T>
asyncSafelyWithoutExceptions
Link copied to clipboard
inline fun <T> CoroutineScope.asyncSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> T): Deferred<T?>
inline fun <T> CoroutineScope.asyncSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> T): Deferred<T?>
inline fun <T> CoroutineScope.asyncSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> T): Deferred<T?>
awaitFirst
Link copied to clipboard
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(cancelOthers: Boolean = true): T
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(scope: CoroutineScope, cancelOnResult: Boolean = true): T
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(cancelOthers: Boolean = true): T
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(scope: CoroutineScope, cancelOnResult: Boolean = true): T
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(cancelOthers: Boolean = true): T
suspend fun <T> Iterable<Deferred<T>>.awaitFirst(scope: CoroutineScope, cancelOnResult: Boolean = true): T
awaitFirstWithDeferred
Link copied to clipboard
suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(scope: CoroutineScope, cancelOnResult: Boolean = true): Pair<Deferred<T>, T>
suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(scope: CoroutineScope, cancelOnResult: Boolean = true): Pair<Deferred<T>, T>
suspend fun <T> Iterable<Deferred<T>>.awaitFirstWithDeferred(scope: CoroutineScope, cancelOnResult: Boolean = true): Pair<Deferred<T>, T>
buildAction
Link copied to clipboard
fun <T, O> Deferred<T>.buildAction(callback: suspend (T) -> O): DeferredAction<T, O>
fun <T, O> Deferred<T>.buildAction(callback: suspend (T) -> O): DeferredAction<T, O>
fun <T, O> Deferred<T>.buildAction(callback: suspend (T) -> O): DeferredAction<T, O>
contextSafelyExceptionHandler
Link copied to clipboard
inline suspend fun contextSafelyExceptionHandler(): ContextSafelyExceptionHandler?
inline suspend fun contextSafelyExceptionHandler(): ContextSafelyExceptionHandler?
inline suspend fun contextSafelyExceptionHandler(): ContextSafelyExceptionHandler?
CoroutineScope
Link copied to clipboard
inline fun CoroutineScope(context: CoroutineContext, noinline defaultExceptionsHandler: ExceptionHandler<Unit>): CoroutineScope
inline fun CoroutineScope(context: CoroutineContext, noinline defaultExceptionsHandler: ExceptionHandler<Unit>): CoroutineScope
inline fun CoroutineScope(context: CoroutineContext, noinline defaultExceptionsHandler: ExceptionHandler<Unit>): CoroutineScope
createActionsActor
Link copied to clipboard
fun CoroutineScope.createActionsActor(): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

fun CoroutineScope.createActionsActor(): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

fun CoroutineScope.createActionsActor(): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

createSafeActionsActor
Link copied to clipboard
inline fun CoroutineScope.createSafeActionsActor(noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

inline fun CoroutineScope.createSafeActionsActor(noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

inline fun CoroutineScope.createSafeActionsActor(noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler): Channel<suspend () -> Unit>

Planned to use with doWithSuspending. Will execute incoming lambdas sequentially

doIn
Link copied to clipboard
inline suspend fun <T> doIn(context: CoroutineContext, noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doIn(context: CoroutineContext, noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doIn(context: CoroutineContext, noinline block: suspend CoroutineScope.() -> T): T
doInDefault
Link copied to clipboard
inline suspend fun <T> doInDefault(noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doInDefault(noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doInDefault(noinline block: suspend CoroutineScope.() -> T): T
doInIO
Link copied to clipboard
inline suspend fun <T> doInIO(noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doInIO(noinline block: suspend CoroutineScope.() -> T): T
doInUI
Link copied to clipboard
inline suspend fun <T> doInUI(noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doInUI(noinline block: suspend CoroutineScope.() -> T): T
inline suspend fun <T> doInUI(noinline block: suspend CoroutineScope.() -> T): T
doOutsideOfCoroutine
Link copied to clipboard
suspend fun <T> doOutsideOfCoroutine(block: () -> T): T

Call this method in case you need to do something in common thread (like reading of file in JVM)

suspend fun <T> doOutsideOfCoroutine(block: () -> T): T

Call this method in case you need to do something in common thread (like reading of file in JVM)

suspend fun <T> doOutsideOfCoroutine(block: () -> T): T

Call this method in case you need to do something in common thread (like reading of file in JVM)

doSynchronously
Link copied to clipboard
fun <T> doSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> CoroutineScope.doSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> doSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> CoroutineScope.doSynchronously(block: suspend CoroutineScope.() -> T): T
doWithSuspending
Link copied to clipboard
suspend fun <T> Channel<suspend () -> Unit>.doWithSuspending(action: ActorAction<T>): T

Must be use with actor created by createActionsActor or createSafeActionsActor. Will send lambda which will execute action and return result.

suspend fun <T> Channel<suspend () -> Unit>.doWithSuspending(action: ActorAction<T>): T

Must be use with actor created by createActionsActor or createSafeActionsActor. Will send lambda which will execute action and return result.

suspend fun <T> Channel<suspend () -> Unit>.doWithSuspending(action: ActorAction<T>): T

Must be use with actor created by createActionsActor or createSafeActionsActor. Will send lambda which will execute action and return result.

filterNotNull
Link copied to clipboard
fun <T> Flow<T>.filterNotNull(): Flow<T & Any>
fun <T> Flow<T>.filterNotNull(): Flow<T & Any>
fun <T> Flow<T>.filterNotNull(): Flow<T & Any>
first
Link copied to clipboard
suspend fun <T> List<Deferred<T>>.first(scope: CoroutineScope, cancelOnResult: Boolean = true): T
suspend fun <T> List<Deferred<T>>.first(scope: CoroutineScope, cancelOnResult: Boolean = true): T
suspend fun <T> List<Deferred<T>>.first(scope: CoroutineScope, cancelOnResult: Boolean = true): T
firstNotNull
Link copied to clipboard
suspend fun <T> Flow<T?>.firstNotNull(): T
suspend fun <T> Flow<T?>.firstNotNull(): T
suspend fun <T> Flow<T?>.firstNotNull(): T
firstOf
Link copied to clipboard
suspend fun <T> CoroutineScope.firstOf(vararg variants: Deferred<T>, cancelOnResult: Boolean = true): T
suspend fun <T> CoroutineScope.firstOf(cancelOnResult: Boolean = true, block: DoWithFirstBuilder<T>.() -> Unit): T
suspend fun <T> CoroutineScope.firstOf(variants: Iterable<Deferred<T>>, cancelOnResult: Boolean = true): T
suspend fun <T> CoroutineScope.firstOf(vararg variants: Deferred<T>, cancelOnResult: Boolean = true): T
suspend fun <T> CoroutineScope.firstOf(cancelOnResult: Boolean = true, block: DoWithFirstBuilder<T>.() -> Unit): T
suspend fun <T> CoroutineScope.firstOf(variants: Iterable<Deferred<T>>, cancelOnResult: Boolean = true): T
suspend fun <T> CoroutineScope.firstOf(vararg variants: Deferred<T>, cancelOnResult: Boolean = true): T
suspend fun <T> CoroutineScope.firstOf(cancelOnResult: Boolean = true, block: DoWithFirstBuilder<T>.() -> Unit): T
suspend fun <T> CoroutineScope.firstOf(variants: Iterable<Deferred<T>>, cancelOnResult: Boolean = true): T
flatMap
Link copied to clipboard
@JvmName(name = "flatMapIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
inline fun <T, R> Flow<Flow<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
@JvmName(name = "flatMapIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
inline fun <T, R> Flow<Flow<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
@JvmName(name = "flatMapIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
inline fun <T, R> Flow<Flow<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
flatMapNotNull
Link copied to clipboard
@JvmName(name = "flatMapNotNullIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
inline fun <T, R> Flow<Flow<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
@JvmName(name = "flatMapNotNullIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
inline fun <T, R> Flow<Flow<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
@JvmName(name = "flatMapNotNullIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
inline fun <T, R> Flow<Flow<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
flatten
Link copied to clipboard
@JvmName(name = "flattenIterable")
fun <T> Flow<Iterable<T>>.flatten(): Flow<T>
fun <T> Flow<Flow<T>>.flatten(): Flow<T>
@JvmName(name = "flattenIterable")
fun <T> Flow<Iterable<T>>.flatten(): Flow<T>
fun <T> Flow<Flow<T>>.flatten(): Flow<T>
@JvmName(name = "flattenIterable")
fun <T> Flow<Iterable<T>>.flatten(): Flow<T>
fun <T> Flow<Flow<T>>.flatten(): Flow<T>
invoke
Link copied to clipboard
inline suspend operator fun <T> FlowCollector<T>.invoke(value: T)
inline suspend operator fun <T> FlowCollector<T>.invoke(value: T)
inline suspend operator fun <T> FlowCollector<T>.invoke(value: T)
invokeFirstOf
Link copied to clipboard
suspend fun <O> Iterable<DeferredAction<*, O>>.invokeFirstOf(scope: CoroutineScope, cancelOnResult: Boolean = true): O
suspend fun <O> invokeFirstOf(    scope: CoroutineScope,     vararg variants: DeferredAction<*, O>,     cancelOnResult: Boolean = true): O
suspend fun <O> Iterable<DeferredAction<*, O>>.invokeFirstOf(scope: CoroutineScope, cancelOnResult: Boolean = true): O
suspend fun <O> invokeFirstOf(    scope: CoroutineScope,     vararg variants: DeferredAction<*, O>,     cancelOnResult: Boolean = true): O
suspend fun <O> Iterable<DeferredAction<*, O>>.invokeFirstOf(scope: CoroutineScope, cancelOnResult: Boolean = true): O
suspend fun <O> invokeFirstOf(    scope: CoroutineScope,     vararg variants: DeferredAction<*, O>,     cancelOnResult: Boolean = true): O
invokeOnFirst
Link copied to clipboard
suspend fun <T, O> Iterable<Deferred<T>>.invokeOnFirst(    scope: CoroutineScope,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
suspend fun <T, O> invokeOnFirst(    scope: CoroutineScope,     vararg variants: Deferred<T>,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
suspend fun <T, O> Iterable<Deferred<T>>.invokeOnFirst(    scope: CoroutineScope,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
suspend fun <T, O> invokeOnFirst(    scope: CoroutineScope,     vararg variants: Deferred<T>,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
suspend fun <T, O> Iterable<Deferred<T>>.invokeOnFirst(    scope: CoroutineScope,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
suspend fun <T, O> invokeOnFirst(    scope: CoroutineScope,     vararg variants: Deferred<T>,     cancelOnResult: Boolean = true,     callback: suspend (T) -> O): O
invokeOnFirstOf
Link copied to clipboard
suspend fun <T, O> CoroutineScope.invokeOnFirstOf(    cancelOnResult: Boolean = true,     block: DoWithFirstBuilder<T>.() -> Unit,     callback: suspend (T) -> O): O
suspend fun <T, O> CoroutineScope.invokeOnFirstOf(    cancelOnResult: Boolean = true,     block: DoWithFirstBuilder<T>.() -> Unit,     callback: suspend (T) -> O): O
suspend fun <T, O> CoroutineScope.invokeOnFirstOf(    cancelOnResult: Boolean = true,     block: DoWithFirstBuilder<T>.() -> Unit,     callback: suspend (T) -> O): O
launchSafely
Link copied to clipboard
inline fun CoroutineScope.launchSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> Unit): Job
inline fun CoroutineScope.launchSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> Unit): Job
inline fun CoroutineScope.launchSafely(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend CoroutineScope.() -> Unit): Job
launchSafelyWithoutExceptions
Link copied to clipboard
inline fun CoroutineScope.launchSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> Unit): Job
inline fun CoroutineScope.launchSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> Unit): Job
inline fun CoroutineScope.launchSafelyWithoutExceptions(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     noinline onException: ExceptionHandler<Unit?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend CoroutineScope.() -> Unit): Job
launchSynchronously
Link copied to clipboard
fun <T> launchSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> CoroutineScope.launchSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> launchSynchronously(block: suspend CoroutineScope.() -> T): T
fun <T> CoroutineScope.launchSynchronously(block: suspend CoroutineScope.() -> T): T
LinkedSupervisorJob
Link copied to clipboard
fun CoroutineContext.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): CoroutineContext
fun CoroutineScope.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): CoroutineContext
fun CoroutineContext.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): Job
fun CoroutineScope.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): Job
fun CoroutineContext.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): CoroutineContext
fun CoroutineScope.LinkedSupervisorJob(additionalContext: CoroutineContext? = null): CoroutineContext
LinkedSupervisorScope
Link copied to clipboard
fun CoroutineScope.LinkedSupervisorScope(additionalContext: CoroutineContext? = null): CoroutineScope
fun CoroutineScope.LinkedSupervisorScope(additionalContext: CoroutineContext? = null): CoroutineScope
fun CoroutineScope.LinkedSupervisorScope(additionalContext: CoroutineContext? = null): CoroutineScope
plus
Link copied to clipboard
inline operator fun <T> Flow<T>.plus(other: Flow<T>): Flow<T>
inline operator fun <T> Flow<T>.plus(other: Flow<T>): Flow<T>
inline operator fun <T> Flow<T>.plus(other: Flow<T>): Flow<T>
runCatchingSafely
Link copied to clipboard
inline suspend fun <T> runCatchingSafely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): Result<T>
inline suspend fun <T> runCatchingSafely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): Result<T>
inline suspend fun <T> runCatchingSafely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): Result<T>
runCatchingSafelyWithoutExceptions
Link copied to clipboard
inline suspend fun <T> runCatchingSafelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): Result<T?>
inline suspend fun <T> runCatchingSafelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): Result<T?>
inline suspend fun <T> runCatchingSafelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): Result<T?>
safeActor
Link copied to clipboard
inline fun <T> CoroutineScope.safeActor(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     crossinline block: suspend (T) -> Unit): Channel<T>
inline fun <T> CoroutineScope.safeActor(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     crossinline block: suspend (T) -> Unit): Channel<T>
inline fun <T> CoroutineScope.safeActor(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     crossinline block: suspend (T) -> Unit): Channel<T>
safeActorAsync
Link copied to clipboard
inline fun <T> CoroutineScope.safeActorAsync(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline markerFactory: suspend (T) -> Any? = { null },     crossinline block: suspend (T) -> Unit): Channel<T>
inline fun <T> CoroutineScope.safeActorAsync(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline markerFactory: suspend (T) -> Any? = { null },     crossinline block: suspend (T) -> Unit): Channel<T>
inline fun <T> CoroutineScope.safeActorAsync(    channelCapacity: Int = Channel.UNLIMITED,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline markerFactory: suspend (T) -> Any? = { null },     crossinline block: suspend (T) -> Unit): Channel<T>
safely
Link copied to clipboard
inline suspend fun <T> safely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): T

It will run block inside of supervisorScope to avoid problems with catching of exceptions

inline suspend fun <T> safely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): T

It will run block inside of supervisorScope to avoid problems with catching of exceptions

inline suspend fun <T> safely(noinline onException: ExceptionHandler<T> = defaultSafelyExceptionHandler, noinline block: suspend CoroutineScope.() -> T): T

It will run block inside of supervisorScope to avoid problems with catching of exceptions

safelyWithContextExceptionHandler
Link copied to clipboard
suspend fun <T> safelyWithContextExceptionHandler(    contextExceptionHandler: ExceptionHandler<Unit>,     safelyExceptionHandler: ExceptionHandler<T> = defaultSafelyExceptionHandler,     block: suspend CoroutineScope.() -> T): T

This method will set new coroutineContext with ContextSafelyExceptionHandler. In case if coroutineContext already contains ContextSafelyExceptionHandler, ContextSafelyExceptionHandler.handler will be used BEFORE contextExceptionHandler in case of exception.

suspend fun <T> safelyWithContextExceptionHandler(    contextExceptionHandler: ExceptionHandler<Unit>,     safelyExceptionHandler: ExceptionHandler<T> = defaultSafelyExceptionHandler,     block: suspend CoroutineScope.() -> T): T

This method will set new coroutineContext with ContextSafelyExceptionHandler. In case if coroutineContext already contains ContextSafelyExceptionHandler, ContextSafelyExceptionHandler.handler will be used BEFORE contextExceptionHandler in case of exception.

suspend fun <T> safelyWithContextExceptionHandler(    contextExceptionHandler: ExceptionHandler<Unit>,     safelyExceptionHandler: ExceptionHandler<T> = defaultSafelyExceptionHandler,     block: suspend CoroutineScope.() -> T): T

This method will set new coroutineContext with ContextSafelyExceptionHandler. In case if coroutineContext already contains ContextSafelyExceptionHandler, ContextSafelyExceptionHandler.handler will be used BEFORE contextExceptionHandler in case of exception.

safelyWithoutExceptions
Link copied to clipboard
inline suspend fun <T> safelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): T?

Shortcut for safely with exception handler, that as expected must return null in case of impossible creating of result from exception (instead of throwing it, by default always returns null)

inline suspend fun <T> safelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): T?

Shortcut for safely with exception handler, that as expected must return null in case of impossible creating of result from exception (instead of throwing it, by default always returns null)

inline suspend fun <T> safelyWithoutExceptions(noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend CoroutineScope.() -> T): T?

Shortcut for safely with exception handler, that as expected must return null in case of impossible creating of result from exception (instead of throwing it, by default always returns null)

safelyWithResult
Link copied to clipboard
inline suspend fun <T> safelyWithResult(noinline block: suspend CoroutineScope.() -> T): Result<T>
inline suspend fun <T> safelyWithResult(noinline block: suspend CoroutineScope.() -> T): Result<T>
inline suspend fun <T> safelyWithResult(noinline block: suspend CoroutineScope.() -> T): Result<T>
subscribe
Link copied to clipboard
inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Shortcut for chain if Flow.onEach and Flow.launchIn

inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Shortcut for chain if Flow.onEach and Flow.launchIn

inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Shortcut for chain if Flow.onEach and Flow.launchIn

subscribeAsync
Link copied to clipboard
fun <T, M> Flow<T>.subscribeAsync(    scope: CoroutineScope,     markerFactory: suspend (T) -> M,     block: suspend (T) -> Unit): Job
fun <T, M> Flow<T>.subscribeAsync(    scope: CoroutineScope,     markerFactory: suspend (T) -> M,     block: suspend (T) -> Unit): Job
fun <T, M> Flow<T>.subscribeAsync(    scope: CoroutineScope,     markerFactory: suspend (T) -> M,     block: suspend (T) -> Unit): Job
subscribeSafely
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafely(    scope: CoroutineScope,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job

Use subscribe, but all blocks will be called inside of safely function. Use onException to set up your reaction for Throwables

inline fun <T> Flow<T>.subscribeSafely(    scope: CoroutineScope,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job

Use subscribe, but all blocks will be called inside of safely function. Use onException to set up your reaction for Throwables

inline fun <T> Flow<T>.subscribeSafely(    scope: CoroutineScope,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job

Use subscribe, but all blocks will be called inside of safely function. Use onException to set up your reaction for Throwables

subscribeSafelyAsync
Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelyAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelyAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelyAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler,     noinline block: suspend (T) -> Unit): Job
subscribeSafelySkippingExceptions
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions inside of safely will be skipped

inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions inside of safely will be skipped

inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions inside of safely will be skipped

subscribeSafelySkippingExceptionsAsync
Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelySkippingExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelySkippingExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelySkippingExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline block: suspend (T) -> Unit): Job
subscribeSafelyWithoutExceptions
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(    scope: CoroutineScope,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions will be passed to defaultSafelyExceptionHandler

inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(    scope: CoroutineScope,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions will be passed to defaultSafelyExceptionHandler

inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(    scope: CoroutineScope,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions will be passed to defaultSafelyExceptionHandler

subscribeSafelyWithoutExceptionsAsync
Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelyWithoutExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelyWithoutExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job
inline fun <T, M> Flow<T>.subscribeSafelyWithoutExceptionsAsync(    scope: CoroutineScope,     noinline markerFactory: suspend (T) -> M,     noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull,     noinline block: suspend (T) -> Unit): Job
takeNotNull
Link copied to clipboard
fun <T> Flow<T>.takeNotNull(): Flow<T & Any>
fun <T> Flow<T>.takeNotNull(): Flow<T & Any>
fun <T> Flow<T>.takeNotNull(): Flow<T & Any>
weakAsync
Link copied to clipboard
fun <T> CoroutineScope.weakAsync(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> T): Deferred<T>
fun <T> CoroutineScope.weakAsync(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> T): Deferred<T>
fun <T> CoroutineScope.weakAsync(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> T): Deferred<T>
weakLaunch
Link copied to clipboard
fun CoroutineScope.weakLaunch(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> Unit): Job
fun CoroutineScope.weakLaunch(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> Unit): Job
fun CoroutineScope.weakLaunch(    context: CoroutineContext = EmptyCoroutineContext,     start: CoroutineStart = CoroutineStart.DEFAULT,     block: suspend CoroutineScope.() -> Unit): Job

Properties

Link copied to clipboard
val <T> T.asDeferred: Deferred<T>
val <T> T.asDeferred: Deferred<T>
val <T> T.asDeferred: Deferred<T>
Link copied to clipboard
val Default: CoroutineDispatcher
val Default: CoroutineDispatcher
val Default: CoroutineDispatcher
Link copied to clipboard
var defaultSafelyExceptionHandler: ExceptionHandler<Nothing>

This instance will be used in all calls of safely where exception handler has not been passed

var defaultSafelyExceptionHandler: ExceptionHandler<Nothing>

This instance will be used in all calls of safely where exception handler has not been passed

var defaultSafelyExceptionHandler: ExceptionHandler<Nothing>

This instance will be used in all calls of safely where exception handler has not been passed

Link copied to clipboard

This instance will be used in all calls of safelyWithoutExceptions as an exception handler for safely call

This instance will be used in all calls of safelyWithoutExceptions as an exception handler for safely call

This instance will be used in all calls of safelyWithoutExceptions as an exception handler for safely call

Use this handler in cases you wish to include handling of exceptions by defaultSafelyWithoutExceptionHandler and returning null at one time

Use this handler in cases you wish to include handling of exceptions by defaultSafelyWithoutExceptionHandler and returning null at one time

Use this handler in cases you wish to include handling of exceptions by defaultSafelyWithoutExceptionHandler and returning null at one time

Link copied to clipboard
val IO: CoroutineDispatcher
val IO: CoroutineDispatcher
Link copied to clipboard
val UI: MainCoroutineDispatcher
val UI: MainCoroutineDispatcher
val UI: MainCoroutineDispatcher