Open MateuszNaKodach opened 3 years ago
If you’re using Kotlin you can also make use of the andThen (infix) function for command composition (import org.occurrent.application.composition.command.andThen):
applicationService.execute(gameId,
{ events -> WordGuessingGame.startNewGame(events, gameId, wordToGuess) }
andThen { events -> WordGuessingGame.makeGuess(events, guess) })
Events returned from WordGuessingGame.startNewGame(..) will be appended to the event stream when calling WordGuessingGame.makeGuess(..) and the new domain events returned by the two functions will be merged and written in an atomic fashion to the event store.
https://occurrent.org/documentation#command-composition