[akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread Ryan Bair
Hi Andrew, There is the defer method which handles this case rather nicely. case Message = val events = ... persist(events) defer() { _ = sender() ! Ack } // Not run until persist completes On Friday, July 17, 2015 at 10:47:01 AM UTC-4, Andrew Easter wrote: I've got a persistent actor

[akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread Andrew Easter
Ah, thanks. I'd got confused and thought the defer behaviour was only relevant when using persistAsync. Need to read the manual properly next time, doh! On Friday, 17 July 2015 16:00:43 UTC+1, Ryan Bair wrote: Hi Andrew, There is the defer method which handles this case rather nicely.

[akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread ahjohannessen
Ryan, I suppose that works because of: val d: ((Unit) ⇒ Unit) ⇒ Unit = defer() ? On Friday, July 17, 2015 at 4:00:43 PM UTC+1, Ryan Bair wrote: Hi Andrew, There is the defer method which handles this case rather nicely. case Message = val events = ... persist(events) defer() { _

[akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread ahjohannessen
Andrew, I have also run into that and never paid much attention to defer, solved my problem in a rather clumsy way: private def processEvents(events: Seq[DomainEvent], cm: CommandMessage)(done: ⇒ Unit): Unit = { val durables = events map { e ⇒ DurableEvent(e, pid).causedBy(cm) }

[akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread ahjohannessen
If that defer works as explained, then I can reduce my code to this: ... val durables = events map { e ⇒ DurableEvent(e, pid).causedBy(cm) } persist(durables)(applyEvent) defer()(_ ⇒ done) ... That's rather nice :) On Friday, July 17, 2015 at 8:04:54 PM UTC+1, ahjohannessen wrote:

Re: [akka-user] Re: Akka persistence - replying to sender after multiple events persisted

2015-07-17 Thread Konrad Malawski
Yep, that's how it works! :-) --  Cheers, Konrad 'ktoso’ Malawski Akka @ Typesafe On 17 July 2015 at 21:11:19, ahjohannessen (ahjohannes...@gmail.com) wrote: If that defer works as explained, then I can reduce my code to this: ... val durables = events map { e ⇒ DurableEvent(e,