Skip to content

Instantly share code, notes, and snippets.

@stasimus
Last active September 11, 2018 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stasimus/bba46cbd5e35c4dbe61b84cac3e52ebe to your computer and use it in GitHub Desktop.
Save stasimus/bba46cbd5e35c4dbe61b84cac3e52ebe to your computer and use it in GitHub Desktop.
class MyPersistentActor extends PersistentActor {
override def receiveCommand: Receive = {
case c: Command ⇒ {
validate(c).foreach { // 1. Validate
events ⇒ persistAsync(events) { // 2. Persist
e ⇒
sender() ! respond(e) // 3. respond to sender
downstream ! e // 4. Apply other side-effects
bi ! AppEvent(currentState, e, context) // 5. Send event/state/context to BI
...
}
}
}
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment