Ghost/ghost/domain-events
2022-10-17 08:41:28 +00:00
..
lib
test Added @tryghost/domain-events package 2021-09-17 15:22:08 +02:00
.eslintrc.js
index.js
package.json
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);