2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00
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 Updated to use assert/strict everywhere (#17047) 2023-06-21 09:56:59 +01:00
.eslintrc.js Updated Eslint ECMAScript compatibility to 2022 2022-08-09 15:51:40 +02:00
index.js Added @tryghost/domain-events package 2021-09-17 15:22:08 +02:00
package.json Updated linting and testing packages 2023-09-01 15:51:17 +02: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);