What is the intended usage of the persist
method in Akka Persistence for sequences of events? I see that there's a signature like this here:
final def persist[A](events: Seq[A])(handler: (A) ⇒ Unit): Unit
but if I try to call it as in the following example
def receiveCommand= {
case x ⇒
val events = Seq(Event("1"), Event("2"))
persist(events) {
e ⇒ println(e) // here it gets printed "List(Event(1),Event(2))"
}
}
I get printed one single event as List(Event(1),Event(2))
. That is, I was expecting to handle each event separately and in the order they are given. But instead, it seems like in the following persist
variant
final def persist[A](event: A)(handler: (A) ⇒ Unit): Unit
the type parameter A
is replaced by Seq[Event]
instead of being replaced by Event
and calling the sequence variant. What is the expected way to use this method?
Thanks.