Ghost/ghost/domain-events
2022-10-17 08:41:28 +00:00
..
lib
test
.eslintrc.js Updated Eslint ECMAScript compatibility to 2022 2022-08-09 15:51:40 +02:00
index.js
package.json Update dependency mocha to v10.1.0 2022-10-17 08:41:28 +00:00
README.md Tidied up package READMEs 2022-07-25 15:17:12 +02:00

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);