carp.core-kotlin
carp.core-kotlin copied to clipboard
Consider using Reaktive for implementing domain events
The following Reactive implementation for Kotlin Multiplatform looks fairly mature: https://github.com/badoo/Reaktive
Rather than using our non-reactive event handling in AggregateRoot we could consider using this library.
Or should we simply use Flow? https://kotlinlang.org/docs/reference/coroutines/flow.html
Once we implement eventing, we should also consider redirecting events from lower-level components to high-level ones.
For example, StudyProtocol right now is composed by several underlying components, including ParticipantDataConfiguration. One of the main reasons StudyProtocol currently overrides implementations of underlying components is to trigger events based on the results of redirecting calls to them. Concretely, this also means that replaceExpectedParticipantData was implemented in StudyProtocol rather than ParticipantDataConfiguration since it was more straightforward to manage events this way.