1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| import { Inject, Post } from '@midwayjs/core';
| import {
| CoolController,
| BaseController,
| CoolEventManager,
| } from '@cool-midway/core';
|
| /**
| * 事件
| */
| @CoolController()
| export class OpenDemoEventController extends BaseController {
| @Inject()
| coolEventManager: CoolEventManager;
|
| @Post('/comm', { summary: '普通事件,本进程生效' })
| async comm() {
| await this.coolEventManager.emit('demo', { a: 2 }, 1);
| return this.ok();
| }
|
| @Post('/global', { summary: '全局事件,多进程都有效' })
| async global() {
| await this.coolEventManager.globalEmit('demo', false, { a: 2 }, 1);
| return this.ok();
| }
| }
|
|