mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 11:55:01 +03:00
34fe49b110
refs https://github.com/TryGhost/Toolbox/issues/501
- this reverts commit
|
||
---|---|---|
.. | ||
lib | ||
test | ||
.eslintrc.js | ||
index.js | ||
package.json | ||
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);