AsyncCompanion

de.rmgk.delay$.AsyncCompanion
trait AsyncCompanion[Ctx]

Companion object of Async, but with a type parameter to allow fine grained type inference. This could potentially be simplified if we ever get named type parameters.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

inline def apply[A](inline expr: Ctx ?=> A): Async[Ctx, A]

Main async syntax. The body expr is not executed until the returned Async is started with delay.run or one of the variants. Any exceptions raised in expr are forwarded to the handler of the async run.

Main async syntax. The body expr is not executed until the returned Async is started with delay.run or one of the variants. Any exceptions raised in expr are forwarded to the handler of the async run.

Attributes

inline def fromCallback[A](inline f: Ctx ?=> Callback[A] ?=> Unit): Async[Ctx, A]

Create a new Async from a callback. f is a block that may pass handler to a callback-based API.

Create a new Async from a callback. f is a block that may pass handler to a callback-based API.

Attributes

Example:
Async.fromCallback {
 fut.onComplete(Async.handler.complete(_))
}
inline def handler[A](using cb: Callback[A]): Callback[A]

Use inside a fromCallback

Use inside a fromCallback

Attributes

inline def resource[R, A](inline open: R, inline close: R => Unit)(inline body: Ctx ?=> R => A): Async[Ctx, A]

Simple form of resource handling given an open and close function for some resource. Makes the resource available inside the async body and ensures it is closed as soon as body is done (exceptionally or normally).

Simple form of resource handling given an open and close function for some resource. Makes the resource available inside the async body and ensures it is closed as soon as body is done (exceptionally or normally).

Attributes

inline def syntax[A](inline expr: A): Async[Ctx, A]

Enables the use of Async.bind inside a sequential looking block.

Enables the use of Async.bind inside a sequential looking block.

Attributes