Skip to content

Instantly share code, notes, and snippets.

@justinhj
Last active December 2, 2019 05:12
Show Gist options
  • Save justinhj/ee7e23443d0c00067c8e3b4332448cdc to your computer and use it in GitHub Desktop.
Save justinhj/ee7e23443d0c00067c8e3b4332448cdc to your computer and use it in GitHub Desktop.
.onCommand[WithdrawCmd, WithdrawalResponse]{
case (WithdrawCmd(time, description, amount), ctx, state) =>
if(state.balance - amount >= 0)
ctx.thenPersist(WithdrawEvt(time, description, amount)){ _ =>
ctx.reply(SuccessfulWithdrawalResponse(state.balance - amount))
}
else {
ctx.reply(FailedWithdrawalResponse(s"Insufficient funds (current balance ${state.balance})"))
ctx.done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment