-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix: lifecycle hook should trigger only one time #168
Conversation
Codecov Report
@@ Coverage Diff @@
## master #168 +/- ##
=======================================
Coverage 89.59% 89.60%
=======================================
Files 51 51
Lines 1096 1097 +1
Branches 181 181
=======================================
+ Hits 982 983 +1
Misses 114 114
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
改动思路或许有点过重了? 而且按照 Spec,生命周期中的 emitHook 其实应该只允许执行一次且必须按照 insert 的顺序执行; 是因为历史问题而没有加校验,是不是应该在 LifecycleManager 里面补全校验逻辑,既能解决问题,也无需引入新概念,反正都是 BREAKING CHANGE |
@noahziheng 阔以,我去改一下 LifecycleManager ,state 这个我也不确定是不是合适,先提出来给大家 review |
789ef01
to
8acdeb9
Compare
@noahziheng 妥了 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,@hyj1991 Need review together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM;
@@ -68,6 +68,8 @@ export class LifecycleManager { | |||
if (!Array.isArray(fnList)) { | |||
return; | |||
} | |||
// lifecycle hook should only trigger one time | |||
this.hookFnMap.delete(hookName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是所有的 hook 都只执行一次吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有需要执行多次的 hook 吗?好像也没有把?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
设计上确实应该执行一次,如果有多次触发的类似事件分发机制的场景,就不该通过 Lifecycle 做,应该考虑 Trigger 或者 EventEmitter
8acdeb9
to
a670349
Compare
Checklist
npm test
passesDescription of change
生命周期的 hooks 应该只执行一次。