Ghost/ghost/domain-events
Simon Backx 520b19e313
Added try catch for errors in all domain event listeners (#15976)
refs https://github.com/TryGhost/Team/issues/2370

Reduces the amount of unhandled errors that could cause a crash in Ghost
2022-12-13 11:28:02 +01:00
..
lib Added try catch for errors in all domain event listeners (#15976) 2022-12-13 11:28:02 +01:00
test Added @tryghost/domain-events package 2021-09-17 15:22:08 +02: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 Added try catch for errors in all domain event listeners (#15976) 2022-12-13 11:28:02 +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);