trait Thereafter[F[_]] extends AnyRef
Typeclass for computations with an operation that can run a side effect after the computation has finished.
The typeclass abstracts the following patterns so that it can be used for types other than scala.concurrent.Future.
future.transform { result => val () = body(result); result } // synchronous body future.transform { result => body(result).transform(_ => result) } // asynchronous body
Usage:
import com.digitalasset.canton.util.Thereafter.syntax.* myAsyncComputation.thereafter(result => ...)
- F
The computation's type functor.
- Alphabetic
- By Inheritance
- Thereafter
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract type Content[_]
The container type for computation result.
Abstract Value Members
- abstract def thereafter[A](f: F[A])(body: (Content[A]) => Unit)(implicit ec: ExecutionContext): F[A]
Runs
body
after the computationf
has completed.Runs
body
after the computationf
has completed.- returns
The computation that results from chaining
f
beforebody
. Completes only afterbody
has run. Ifbody
completes normally, the result of the computation is the same asf
's result. Ifbody
throws, the result includes the thrown exception.
- abstract def thereafterF[A](f: F[A])(body: (Content[A]) => Future[Unit])(implicit ec: ExecutionContext): F[A]
runs
body
after the computationf
has completedruns
body
after the computationf
has completed- returns
The computation that results from chaining
f
beforebody
. Completes only afterbody
has run. Ifbody
completes normally, the result of the computation is the same asf
's result. Ifbody
throws, the result includes the thrown exception. Ifbody
produces a failed computation, the result includes the thrown exception.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])