Last active
September 11, 2018 14:04
-
-
Save stasimus/bba46cbd5e35c4dbe61b84cac3e52ebe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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