Ghost/ghost/domain-events
Daniel Lockyer 48dda23554
Reverted "Added version information to log lines"
refs https://github.com/TryGhost/Toolbox/issues/501

- this reverts commit f2116357b7
- something with Elasticsearch is causing high CPU usage, so this commit
  reverts that for now
2023-01-17 13:20:47 +01:00
..
lib Added DomainEvents.allSettled utility method (#16075) 2023-01-04 14:30:35 +01:00
test Added DomainEvents.allSettled utility method (#16075) 2023-01-04 14:30:35 +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 Reverted "Added version information to log lines" 2023-01-17 13:20:47 +01: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);