Ghost/ghost/domain-events
2024-05-01 17:01:41 +02:00
..
lib Fixed @tryghost/domain-events relying on NODE_ENV 2023-09-02 16:58:48 +07:00
test Updated to use assert/strict everywhere (#17047) 2023-06-21 09:56:59 +01:00
.eslintrc.js
index.js
package.json Update TryGhost packages 2024-05-01 17:01:41 +02: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);