Files
cnpmcore/app/core/service/EventCorkerAdvice.ts
MK (fengmk2) 89f1250927 refactor: use all in one egg v4 (#855)
required https://github.com/eggjs/egg/pull/5654

---------

Signed-off-by: MK (fengmk2) <fengmk2@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-28 22:17:01 +08:00

20 lines
380 B
TypeScript

import { Inject, ObjectInitType, type ContextEventBus } from 'egg';
import { Advice, type IAdvice } from 'egg/aop';
@Advice({
initType: ObjectInitType.CONTEXT,
})
export class EventCorkAdvice implements IAdvice {
@Inject()
private eventBus: ContextEventBus;
async beforeCall() {
this.eventBus.cork();
}
async afterFinally() {
this.eventBus.uncork();
}
}