rokot-notification
Version:
Rokot - [Rocketmakers](http://www.rocketmakers.com/) TypeScript NodeJs Platform
26 lines (25 loc) • 873 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const _ = require("underscore");
class NotificationDispatchHandler {
constructor(transportName, logger, transport) {
this.transportName = transportName;
this.logger = logger;
this.transport = transport;
}
onDispatch(notification, messageHandler) {
if (this.canHandleMessage(messageHandler)) {
return this.invokeMessage(notification, messageHandler);
}
}
canHandleMessage(messageHandler) {
return _.isFunction(messageHandler[this.transportName]);
}
invokeMessage(notification, messageHandler) {
return messageHandler[this.transportName](notification, this.transport);
}
shutdown() {
this.transport.shutdown();
}
}
exports.NotificationDispatchHandler = NotificationDispatchHandler;