ModelTC

@implicitNotFound("Cannot find domain model definition for State: ${State}, Event: ${Event}, Rejection: ${Rejection}") @implicitAmbiguous("Domain model definition must be unique!")
sealed trait ModelTC[State, Event, Rejection]

A type class that captures domain model

note that due to uniqueness requirements for this typeclass, it is sealed and the only way to create an instance is through implementing DomainModel.

so don't create several instances as it is a bad idea and may change your domain model behavior in different contexts!

class Object
trait Matchable
class Any

Value members

Abstract methods

def initial: State
def transition: Event => State => ValidatedNec[Rejection, State]

Concrete methods

final def handle[T](self: State, dec: Decision[Rejection, Event, T]): Decision[Rejection, Event, (State, T)]

like perform, but also returns initial output

like perform, but also returns initial output

final def perform(self: State, dec: Decision[Rejection, Event, Unit]): Decision[Rejection, Event, State]

Returns a decision that has applied this decision and folded state, so the output is new state

Returns a decision that has applied this decision and folded state, so the output is new state