Last active
August 29, 2015 14:00
-
-
Save scullxbones/11388376 to your computer and use it in GitHub Desktop.
Stake in the ground
This file contains hidden or 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
| trait ViewState { self: View => | |
| type State | |
| private val state: State | |
| def handle: Receive = { | |
| case SnapshotOffer(metadata, offeredSnapshot) => state = offeredSnapshot | |
| case p@Persistent(payload, sequenceNr) => | |
| // Handle persistent | |
| case PersistenceFailure(payload, sequenceNr, cause) => | |
| // Handle persistence failure | |
| } | |
| } | |
| trait PersistentViewState extends ViewState with View { | |
| def receive = { | |
| case p @ Persistent(payload, sequenceNr) => | |
| persistToDb(p) | |
| super.handle(p) | |
| case PersistenceFailure(payload, sequenceNr, cause) => | |
| receivePersistenceFailure(payload,sequenceNr,cause) | |
| } | |
| def persistToDb(persistent: Persistent) { | |
| // Transform and persist to DB | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment