rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
34 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventHandler = exports.ONE_YEAR = exports.ONE_MONTH = exports.ONE_WEEK = exports.ONE_DAY = exports.ONE_HOUR = exports.ONE_MINUTE = exports.EventManager = void 0;
/**
* @abstract
* @description Abstract class defining the structure of an event manager.
* Used to manage the lifecycle of events such as subscription, dispatch, and removal.
*/
class EventManager {
}
exports.EventManager = EventManager;
/** Milliseconds in common time units. */
exports.ONE_MINUTE = 60000;
exports.ONE_HOUR = exports.ONE_MINUTE * 60;
exports.ONE_DAY = exports.ONE_HOUR * 24;
exports.ONE_WEEK = exports.ONE_DAY * 7;
exports.ONE_MONTH = exports.ONE_DAY * 30;
exports.ONE_YEAR = exports.ONE_DAY * 365;
/**
* Abstract class representing an event handler.
* @template T - The type of the associated aggregate.
*/
class EventHandler {
params;
constructor(params) {
this.params = params;
if (typeof params?.eventName !== 'string') {
throw new Error('params.eventName is required as string');
}
this.dispatch = this.dispatch.bind(this);
}
}
exports.EventHandler = EventHandler;
//# sourceMappingURL=types.js.map