dispatch<TEvent extends DomainEvent> method
Future<void>
dispatch<TEvent extends DomainEvent>(
- TEvent event, [
- DispatchStrategy? dispatchStrategy
Dispatches the given event
to the registered EventHandler's.
Implementation
Future<void> dispatch<TEvent extends DomainEvent>(
TEvent event, [
DispatchStrategy? dispatchStrategy,
]) async {
final handlers = _eventHandlerStore.getHandlersFor<TEvent>();
for (final observer in _observers) {
observer.onDispatch(event, handlers);
}
await (dispatchStrategy ?? _defaultDispatchStrategy)
.execute(handlers, event, _observers);
}