@grubou/bussy
Version:
Command & query bus implementations
23 lines • 736 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventDispatcherMiddleware = void 0;
class EventDispatcherMiddleware {
constructor(eventBus, next) {
this.eventBus = eventBus;
this.next = next;
}
static build(eventBus) {
return {
chainWith(next) {
return new EventDispatcherMiddleware(eventBus, next);
}
};
}
async handle(command) {
const commandResponse = await this.next.handle(command);
this.eventBus.publish(commandResponse.events);
return commandResponse;
}
}
exports.EventDispatcherMiddleware = EventDispatcherMiddleware;
//# sourceMappingURL=EventDispatcherMiddleware.js.map