arrow-effects-kotlinx-coroutines-data / arrow.effects.coroutines / DeferredK

DeferredK

@higherkind sealed class DeferredK<A> : DeferredKOf<A>, Deferred<A>

A wrapper class for Deferred that either memoizes its result or re-runs the computation each time, based on how it is constructed.

Properties

children open val children: Sequence<Job>
isActive open val isActive: Boolean
isCancelled open val isCancelled: Boolean
isCompleted open val isCompleted: Boolean
key open val key: Key<*>
memoized open var memoized: Deferred<A>
onAwait open val onAwait: SelectClause1<A>
onJoin open val onJoin: SelectClause0

Functions

ap fun <B> ap(fa: DeferredKOf<(A) -> B>): DeferredK<B>
Apply a function inside a DeferredK to the result of this DeferredK
await open suspend fun await(): A
bracketCase fun <B> bracketCase(use: (A) -> DeferredKOf<B>, release: (A, ExitCase<Throwable>) -> DeferredKOf<Unit>): DeferredK<B>
Try-catch-finally in a function way
cancel open fun cancel(): Unit
open fun cancel(cause: Throwable?): Boolean
continueOn fun continueOn(ctx: CoroutineContext): DeferredK<A>
Continue the next computation on a different CoroutineContext.
equals open fun equals(other: Any?): Boolean
flatMap fun <B> flatMap(f: (A) -> DeferredKOf<B>): DeferredK<B>
Maps over the value of the DeferredK and flattens the returned DeferredK
getCancellationException open fun getCancellationException(): CancellationException
getCompleted open fun getCompleted(): A
getCompletionExceptionOrNull open fun getCompletionExceptionOrNull(): Throwable?
hashCode open fun hashCode(): Int
invokeOnCompletion open fun invokeOnCompletion(onCancelling: Boolean, invokeImmediately: Boolean, handler: CompletionHandler): DisposableHandle
open fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle
join open suspend fun join(): Unit
map fun <B> map(f: (A) -> B): DeferredK<B>
Map over the result of the DeferredK
start open fun start(): Boolean
value abstract fun value(): Deferred<A>

Companion Object Functions

async fun <A> async(ctx: CoroutineContext = Dispatchers.Default, scope: CoroutineScope = CoroutineScope(ctx), start: CoroutineStart = CoroutineStart.LAZY, fa: DeferredKProc<A>): DeferredK<A>
Starts a coroutine that’ll run DeferredKProc.
asyncF fun <A> asyncF(scope: CoroutineScope = GlobalScope, ctx: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.LAZY, fa: DeferredKProcF<A>): DeferredK<A>
defer fun <A> defer(ctx: CoroutineContext = Dispatchers.Unconfined, scope: CoroutineScope = CoroutineScope(ctx), start: CoroutineStart = CoroutineStart.LAZY, fa: () -> DeferredKOf<A>): DeferredK<A>
Wraps a function that returns a DeferredK in a DeferredK.
invoke operator fun <A> invoke(ctx: CoroutineContext = Dispatchers.Default, scope: CoroutineScope = CoroutineScope(ctx), start: CoroutineStart = CoroutineStart.LAZY, f: suspend () -> A): DeferredK<A>
Wraps a suspend function in a DeferredKoperator fun <A> invoke(fa: Deferred<A>, scope: CoroutineScope = CoroutineScope(Dispatchers.Unconfined)): DeferredK<A>
Wraps an existing Deferred in DeferredK
just fun <A> just(a: A): DeferredK<A>
Lifts a value a into a DeferredK of A
raiseError fun <A> raiseError(t: Throwable): DeferredK<A>
Creates a failed DeferredK with the throwable
tailRecM fun <A, B> tailRecM(a: A, f: (A) -> DeferredKOf<Either<A, B>>): DeferredK<B>

Extension Functions

await suspend fun <A> DeferredKOf<A>.await(): A
Awaits the value of a DeferredK.
fix fun <A> DeferredKOf<A>.fix(): DeferredK<A>
handleErrorWith fun <A> DeferredKOf<A>.handleErrorWith(f: (Throwable) -> DeferredKOf<A>): DeferredK<A>
Handle errors from MonadThrow
k fun <A> Deferred<A>.k(): DeferredK<A>
Wraps a Deferred with DeferredK
runAsync fun <A> DeferredKOf<A>.runAsync(cb: (Either<Throwable, A>) -> DeferredKOf<Unit>): DeferredK<Unit>
Runs the DeferredK asynchronously and continues with the DeferredK returned by cb.
runAsyncCancellable fun <A> DeferredKOf<A>.runAsyncCancellable(onCancel: OnCancel = OnCancel.Silent, cb: (Either<Throwable, A>) -> DeferredKOf<Unit>): DeferredK<Disposable>
Runs the DeferredK asynchronously and continues with the DeferredK returned by cb. Also provides means to cancel the execution.
scope fun <A> DeferredKOf<A>.scope(): CoroutineScope
Returns the CoroutineScope the DeferredK operates on
unsafeAttemptSync fun <A> DeferredKOf<A>.unsafeAttemptSync(): Try<A>
Wrap unsafeRunSync in Try to catch any thrown errors
unsafeRunAsync fun <A> DeferredKOf<A>.unsafeRunAsync(cb: (Either<Throwable, A>) -> Unit): Unit
Runs the DeferredK asynchronously and then runs the cb. Catches all errors that may be thrown in await. Errors from cb will still throw as expected.
unsafeRunAsyncCancellable fun <A> DeferredKOf<A>.unsafeRunAsyncCancellable(onCancel: OnCancel = OnCancel.Silent, cb: (Either<Throwable, A>) -> Unit): Disposable
unsafeRunSync fun <A> DeferredKOf<A>.unsafeRunSync(): A
Runs this DeferredK with runBlocking. Does not handle errors at all, rethrowing them if they happen. Use unsafeAttemptSync if they should be caught automatically.
value fun <A> DeferredKOf<A>.value(): Deferred<A>
Return the wrapped Deferred from a DeferredK