Ghost/ghost/domain-events
2023-02-16 22:15:50 +00:00
..
lib
test
.eslintrc.js
index.js
package.json Update dependency c8 to v7.13.0 2023-02-16 22:15:50 +00:00
README.md

Domain Events

Usage

const DomainEvents = require('@tryghost/domain-events');

class MyEvent {
    constructor(message) {
        this.timestamp = new Date();
        this.data = {
            message
        };
    }
}

DomainEvents.subscribe(MyEvent, function handler(event) {
    console.log(event.data.message);
});

const event = new MyEvent('hello world');

DomainEvents.dispatch(event);