Skip to content

Instantly share code, notes, and snippets.

@emag
Created December 8, 2024 14:08
Show Gist options
  • Save emag/13c1f6e8718ec4d6dd5e67783eb871f1 to your computer and use it in GitHub Desktop.
Save emag/13c1f6e8718ec4d6dd5e67783eb871f1 to your computer and use it in GitHub Desktop.
BS サービス
object BalanceSheetService
extends BalanceSheet.Service[BsCommand, BsNotification] {
def apply[F[_]: Monad]: App[F, Unit] = App.router {
case BsCommand.Initialize(a, l) =>
for {
ready <- App.state.decide(_.initialize(a, l))
aggId <- App.aggregateId
_ <- App.publish(BsNotification.BalanceSheetPrepared(aggId, ready))
} yield ()
case BsCommand.Journalize(e) =>
for {
ready <- App.state.decide(_.journalize(e))
aggId <- App.aggregateId
_ <- App.publish(BsNotification.BalanceSheetUpdated(aggId, ready))
} yield ()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment