Ghost/ghost/milestones/lib/MilestoneCreatedEvent.js
Aileen Nowak 513b7d1df4 Added MilestoneCreatedEvent using DomainEvents
no issue

- In preparation of using event emitting for Milestone achievements, we needed to add a dedicated `MilestoneCreatedEvent` to the `Milestone` entity.
- The event will be emitted using `DomainEvents` when a new milesteone is saved, which will allow us to listen to these events.
2023-02-15 14:28:57 +02:00

23 lines
514 B
JavaScript

/**
* @typedef {object} MilestoneCreatedEventData
*/
module.exports = class MilestoneCreatedEvent {
/**
* @param {MilestoneCreatedEventData} data
* @param {Date} timestamp
*/
constructor(data, timestamp) {
this.data = data;
this.timestamp = timestamp;
}
/**
* @param {MilestoneCreatedEventData} data
* @param {Date} [timestamp]
*/
static create(data, timestamp) {
return new MilestoneCreatedEvent(data, timestamp ?? new Date);
}
};