事件
事件组件是基于 eventemitter2 实现的,提供了强大的事件处理能力。
相关信息:
描述 | |
---|---|
可用于标准项目 | ✅ |
可用于 Serverless | ✅ |
可用于一体化 | ✅ |
包含独立主框架 | ❌ |
包含独立日志 | ❌ |
安装依赖
$ npm i @midwayjs/event-emitter@3 --save
或者在 package.json
中增加依赖后,重新安装
{
"dependencies": {
"@midwayjs/event-emitter": "^3.0.0"
}
}
使用组件
首先在 configuration.ts
中引入组件:
import { Configuration } from '@midwayjs/core';
import * as eventEmitter from '@midwayjs/event-emitter';
@Configuration({
imports: [
// ...
eventEmitter
]
})
export class MainConfiguration {
}