Ghost/ghost/domain-events
Fabien "egg" O'Carroll af9be12a08 Fixed @tryghost/domain-events relying on NODE_ENV
When using this package without setting a NODE_ENV environment variable it would
completely crash.
2023-09-02 16:58:48 +07:00
..
lib Fixed @tryghost/domain-events relying on NODE_ENV 2023-09-02 16:58:48 +07:00
test
.eslintrc.js
index.js
package.json Updated linting and testing packages 2023-09-01 15:51:17 +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);