Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. trait AggregateRoot[AR <: AggregateRoot[AR, Event], Event] extends EventSourced[AR, Event] {
  2. def uncommittedEvents: List[Event]
  3.  
  4. def markCommitted: AR
  5. }
  6.  
  7. trait AggregateFactory[AR <: AggregateRoot[AR, Event], Event] extends EventSourced[AR, Event] {
  8. def loadFromHistory(history: Iterable[Event]): AR = {
  9. var aggregate = applyEvent(history.head)
  10. for (event <- history.tail)
  11. aggregate = aggregate.applyEvent(event)
  12. return aggregate.markCommitted
  13. }
  14. }
Add Comment
Please, Sign In to add comment