Dsl

data class Dsl<A>(val dsl: suspend ResourceScope.() -> A) : Resource<A>

Constructors

Link copied to clipboard
fun <A> Dsl(dsl: suspend ResourceScope.() -> A)

Functions

Link copied to clipboard
fun <B> ap(ff: Resource<(A) -> B>): Resource<B>
Link copied to clipboard
fun <B> flatMap(f: (A) -> Resource<B>): Resource<B>

Create a resource value of B from a resource A by mapping f.

Link copied to clipboard
fun <B> map(f: suspend (A) -> B): Resource<B>
Link copied to clipboard
fun <B, C> parZip(fb: Resource<B>, f: suspend (A, B) -> C): Resource<C>

fun <B, C> parZip(    ctx: CoroutineContext = Dispatchers.Default,     fb: Resource<B>,     f: suspend (A, B) -> C): Resource<C>

Composes two Resources together by zipping them in parallel, by running both their acquire handlers in parallel, and both release handlers in parallel.

Link copied to clipboard
fun tap(f: suspend (A) -> Unit): Resource<A>

Useful for setting up/configuring an acquired resource

Link copied to clipboard
infix suspend tailrec fun <B> use(f: suspend (A) -> B): B

Use the created resource When done will run all finalizers

Link copied to clipboard
fun <B> zip(other: Resource<B>): Resource<Pair<A, B>>
inline fun <B, C> zip(other: Resource<B>, crossinline combine: (A, B) -> C): Resource<C>
inline fun <B, C, D, E> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     crossinline map: (A, B, C, D) -> E): Resource<E>
inline fun <B, C, D, E, F, G> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     crossinline map: (A, B, C, D, E) -> G): Resource<G>
inline fun <B, C, D, E, F, G, H> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     f: Resource<F>,     crossinline map: (A, B, C, D, E, F) -> G): Resource<G>
inline fun <B, C, D, E, F, G, H> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     f: Resource<F>,     g: Resource<G>,     crossinline map: (A, B, C, D, E, F, G) -> H): Resource<H>
inline fun <B, C, D, E, F, G, H, I> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     f: Resource<F>,     g: Resource<G>,     h: Resource<H>,     crossinline map: (A, B, C, D, E, F, G, H) -> I): Resource<I>
inline fun <B, C, D, E, F, G, H, I, J> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     f: Resource<F>,     g: Resource<G>,     h: Resource<H>,     i: Resource<I>,     crossinline map: (A, B, C, D, E, F, G, H, I) -> J): Resource<J>
inline fun <B, C, D, E, F, G, H, I, J, K> zip(    b: Resource<B>,     c: Resource<C>,     d: Resource<D>,     e: Resource<E>,     f: Resource<F>,     g: Resource<G>,     h: Resource<H>,     i: Resource<I>,     j: Resource<J>,     crossinline map: (A, B, C, D, E, F, G, H, I, J) -> K): Resource<K>

inline fun <B, C, D> zip(    b: Resource<B>,     c: Resource<C>,     crossinline map: (A, B, C) -> D): Resource<D>

Combines two independent resource values with the provided map function, returning the resulting immutable Resource value. The finalizers run in order of left to right by using flatMap under the hood, but zip provides a nicer syntax for combining values that don't depend on each-other.

Properties

Link copied to clipboard
val dsl: suspend ResourceScope.() -> A