Ghost/ghost/domain-events
Daniel Lockyer 73bd9a8e1a
Deleted typescript config files
- these aren't needed any more because the packages are in the same repo
  as Ghost, so jsdocs + types should Just Work ™️
2022-08-03 12:49:32 +02:00
..
lib Added @tryghost/domain-events package 2021-09-17 15:22:08 +02:00
test Added @tryghost/domain-events package 2021-09-17 15:22:08 +02:00
.eslintrc.js Removed @babel/eslint-parser, set ecmaVersion instead 2022-02-15 12:30:17 +00:00
index.js Added @tryghost/domain-events package 2021-09-17 15:22:08 +02:00
package.json Removed repository from component package.json files 2022-07-25 11:15:16 +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);