mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
308a28d31a
refs https://github.com/TryGhost/Toolbox/issues/354 - these READMEs were migrated over from when each package was in a different repo - they also assume you're going to be publishing the packages because it mentions install instructions - only a few of them contain custom content - this commit deletes the majority of these files because they're now not useful - any that contained other instructions have been cut down
25 lines
410 B
Markdown
25 lines
410 B
Markdown
# Domain Events
|
|
|
|
## Usage
|
|
|
|
```js
|
|
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);
|
|
```
|