final class EventHandlerBuilder[State >: Null, Event] extends AnyRef
- Alphabetic
- By Inheritance
- EventHandlerBuilder
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new EventHandlerBuilder()
Value Members
- def build(): EventHandler[State, Event]
-
def
forAnyState(): EventHandlerBuilderByState[State, State, Event]
The handlers defined by this builder are used for any state.
The handlers defined by this builder are used for any state. This variant is particular useful for models that have a single type (ie: no class hierarchy).
Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers. Extra care should be taken when using forAnyState as it will match any state. Any event handler define after it will never be reached.
- returns
A new, mutable, EventHandlerBuilderByState
-
def
forNonNullState(): EventHandlerBuilderByState[State, State, Event]
The handlers defined by this builder are used for any not
null
state.The handlers defined by this builder are used for any not
null
state.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers.
- returns
A new, mutable, EventHandlerBuilderByState
-
def
forNullState(): EventHandlerBuilderByState[State, State, Event]
The handlers defined by this builder are used when the state is
null
.The handlers defined by this builder are used when the state is
null
. This variant is particular useful when the empty state of your model is defined asnull
.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers.
- returns
A new, mutable, EventHandlerBuilderByState
-
def
forState[S <: State](stateClass: Class[S], statePredicate: Predicate[S]): EventHandlerBuilderByState[S, State, Event]
Use this method to define event handlers that are selected when the passed predicate holds true for a given subtype of your model.
Use this method to define event handlers that are selected when the passed predicate holds true for a given subtype of your model. Useful when the model is defined as class hierarchy.
Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers.
- stateClass
The handlers defined by this builder are used when the state is an instance of the
stateClass
- statePredicate
The handlers defined by this builder are used when the
statePredicate
istrue
- returns
A new, mutable, EventHandlerBuilderByState
-
def
forState(statePredicate: Predicate[State]): EventHandlerBuilderByState[State, State, Event]
Use this method to define event handlers that are selected when the passed predicate holds true.
Use this method to define event handlers that are selected when the passed predicate holds true.
Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers.
- statePredicate
The handlers defined by this builder are used when the
statePredicate
istrue
- returns
A new, mutable, EventHandlerBuilderByState
-
def
forStateType[S <: State](stateClass: Class[S]): EventHandlerBuilderByState[S, State, Event]
Use this method to define command handlers for a given subtype of your model.
Use this method to define command handlers for a given subtype of your model. Useful when the model is defined as class hierarchy.
Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your event handlers.
- stateClass
The handlers defined by this builder are used when the state is an instance of the
stateClass
- returns
A new, mutable, EventHandlerBuilderByState