Register events using decorators on service methods
MIT License
@dimkl/events
is a dependency-free JS library for listening & dispatching events on class methods.
Use the package manager npm to install @dimkl/events
npm install @dimkl/events
"experimentalDecorators": true
Examples can be found in examples/
folder:
Execute npm run setup:examples
npm test
For feature request or issues contact me via email or open an issue in repo
npm version {patch|minor|major}
npm publish
The injected event types will be used with @on
decorator methods and they should be
defined using interface merging strategy. Example:
declare global {
interface {{eventName}}Event extends IEvent {
type: "{{eventName}}"
data?: {{any_data_type}}
}
interface Events {
"{{eventName}}": {{eventName}}Event
}
}
You can also check the ErrorEvent
definition in codebase.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.