-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
功能请求:希望增加“事件驱动”注解 #3073
Labels
type: enhancement
New feature or request
Comments
czy88840616
added
pr: new feature
This PR adds a new API or behavior.
type: enhancement
New feature or request
and removed
pr: new feature
This PR adds a new API or behavior.
labels
Jul 10, 2023
定义装饰器
事件管理器 (Singleton)
在 onReady 的时候调用 register 注册事件
不足之处还望各位大佬指教 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
功能请求:希望增加“事件驱动”注解
参考:https://nest.nodejs.cn/techniques/events
具体用途:
例如,在用户注册后,为新用户赠送积分,赠送优惠券,为当前推广人增加推广人数,以及一些临时活动等等操作,如果都写到用户注册相关的service中,不同的业务逻辑代码就会紧紧的耦合在一起。如果新的活动增加和取消,又要更改新的代码。
如果采用事件驱动的方式,只需要在注册后发送一个事件,让其他业务去监听注册事件即可。
伪代码实现如下
其他可选选项
1.是否获取事件结果值
2.是异步还是同步
3.监听者遇到错误时事件发布者是否继续执行
4.等等
The text was updated successfully, but these errors were encountered: