I'm looking at domain events, specifically at 2 possibilities:
A. Using "generic" events like that:
public class OrderStateChangedEvent : IEvent
{
public Guid OrderId { get; }
public OrderState NewState { get; }
}
then the consumer would figure out the new state and do something. Since I'm using Rx this would be not that hard (and way better than a switch/case):
var subscription = DomainEvents
.AsObservable<OrderStateChangedEvent>()
.Where(e => e.NewState == OrderState.OrderCompleted)
.Subscribe(OnOrderCompleted);
B. Using specific events:
public class OrderCompletedEvent : IEvent
{
public Guid OrderId { get; }
}
this would lead to way more event classes, which on one hand may get too many, on the other hand event class names contain language and this may be a plus point.
Do you have any recommendations? I'm not experienced with domain events and can't really make a qualified decision here (both seem not to have any major drawbacks)