Ghost/ghost/domain-events
2023-07-11 15:26:07 +02:00
..
lib Added DomainEvents.allSettled utility method (#16075) 2023-01-04 14:30:35 +01:00
test Updated to use assert/strict everywhere (#17047) 2023-06-21 09:56:59 +01:00
.eslintrc.js
index.js
package.json Update Test & linting packages 2023-07-11 15:26:07 +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);