trait Thereafter[F[_], Content[_]] extends Any
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.
- Content
The container type for computation result. Functionally dependent on
F
.
- Alphabetic
- By Inheritance
- Thereafter
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def getClass(): Class[_ <: AnyRef]
- Definition Classes
- Any
- 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
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def equals(arg0: Any): Boolean
- Definition Classes
- Any
- def hashCode(): Int
- Definition Classes
- Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def toString(): String
- Definition Classes
- Any