Skip to content
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

关于事件重复绑定及解绑 #18

Open
hotoo opened this issue Aug 13, 2014 · 2 comments
Open

关于事件重复绑定及解绑 #18

hotoo opened this issue Aug 13, 2014 · 2 comments

Comments

@hotoo
Copy link
Member

hotoo commented Aug 13, 2014

var evt = new Events();

var name = "event-name";
function handler(){}

evt.on(name, handler); // 绑定第一次
evt.on(name, handler); // 绑定第二次

evt.emit(name); // handler 执行两次

evt.off(name, handler); // 解绑一次
evt.emit(name); // handler 不执行。

这个逻辑是否不正常?解绑时,在找到第一个 handler 后是否应该 break ?

@afc163
Copy link
Member

afc163 commented Aug 13, 2014

我怎么觉得合理。。

@hotoo
Copy link
Member Author

hotoo commented Aug 13, 2014

如果这是合理的,那更合理的就是不应该支持重复绑定。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants