Skip to content

Instantly share code, notes, and snippets.

@brianhsu
Created April 8, 2018 03:23
Show Gist options
  • Save brianhsu/7e97bfb94df605f030c675330e1fb973 to your computer and use it in GitHub Desktop.
Save brianhsu/7e97bfb94df605f030c675330e1fb973 to your computer and use it in GitHub Desktop.
abstract class UseCaseExecutor {
def execute[T](useCase: UseCase[T]): Try[T] = {
Try {
useCase.validate().foreach { error => throw error }
val result = useCase.execute()
useCase.journal.foreach(appendJournal)
result
}
}
def appendJournal(journal: Journal): Unit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment