OptionReaction

io.github.positionpal.reaction.ReactionADT.OptionReaction
trait OptionReaction[E, S, T] extends ComposableReaction[E, S, Option[T]], FilterableReaction[E, S, Option[T]]

A specialized version of ReactionADT where the result of the reaction is wrapped in an Option. This trait provides composition and filtering for reactions that return an Option[T].

Type parameters

T

The type of the result wrapped in the Option.

Attributes

Graph
Supertypes
trait FilterableReaction[E, S, Option[T]]
trait ComposableReaction[E, S, Option[T]]
trait ReactionADT[E, S, Option[T]]
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited and Abstract types

opaque type Reaction[F[_]]

Represent the reaction that's triggered within a specific Context

Represent the reaction that's triggered within a specific Context

Type parameters

F

The effect to apply

Attributes

Inherited from:
ReactionADT

Represent the result of the reaction

Represent the result of the reaction

Attributes

Inherited from:
ReactionADT

Value members

Inherited methods

def on[F[_]](reaction: Context[E, S] => F[Option[T]]): Reaction[F]

Create a reaction on an given Context

Create a reaction on an given Context

Value parameters

reaction

The function representing the reaction.

Attributes

Returns

The Reaction object.

Inherited from:
ReactionADT

Extensions

Extensions

extension [F[_]](reaction: Reaction[F])(using evidence$1: Monad[F])
def andThen: Reaction[F]

Compose the execution of two Reaction executing this first and then the other provided

Compose the execution of two Reaction executing this first and then the other provided

Value parameters

other

The Reaction to execute after this one

Attributes

Returns

The new Reaction that is the combination of the other two

def filter: Reaction[F]

Execute reaction only if a condition on the Context is met.

Execute reaction only if a condition on the Context is met.

Value parameters

predicate

A function that takes the Context and returns true if the reaction should be executed.

Attributes

Returns

A new Reaction that only runs if the predicate is satisfied.

def orElse(other: Reaction[F]): Reaction[F]

Execute the Reaction if a condition on the Context is met otherwise other will be executed.

Execute the Reaction if a condition on the Context is met otherwise other will be executed.

Value parameters

other

The reaction to execute if the predicate return false

predicate

The predicate that's executed on the context

Attributes

Returns

A new Reaction to reaction if the predicate returns true or other otherwise

Inherited extensions

extension [F[_]](reaction: Reaction[F])(using evidence$1: Monad[F])
def apply: F[Option[T]]

Executes the Reaction producing a ReactionResult

Executes the Reaction producing a ReactionResult

Value parameters

context

The Context in which the Reaction should run

Attributes

Returns

a functional structure F in which the result is contained

Inherited from:
ReactionADT