-
Notifications
You must be signed in to change notification settings - Fork 41
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
trigger('all')的重复回调想法 #13
Comments
我昨天正好也想到这个话题,直觉现有的 all 的设计是有问题的,但是没细想,准备好好看下代码再说。 |
非得要设计个 all 的话,可以让 all 不接受绑定,只接受触发,这样就避免重复的问题了 |
有道理,可以再仔细想想,其实我不太喜欢这个 API ,默认就返回事件名,那么单独绑定后同一个 callback 也能判断了。— On Sat, Mar 1, 2014 at 12:12 PM, wǒ_is神仙 notifications@github.com wrote:
|
为啥要有 all ,有人用过吗? |
同認為 all 無用 |
从未用过all,虽然觉得*比all更好。唯一能想到的用处是,统计这个事件对象总共触发了多少次事件比较方便。 |
我有过这样的需求,但都是在自己的业务逻辑中实现。 案例我的观点
|
all 借鉴自 Backbone 的 API: http://backbonejs.org/#Events-catalog 如果我们实际上用不到,可以考虑去除。 |
触发两次,好像不是 bug,本身就如此设计的。谁测测 Backbone 目前的逻辑。 |
backbone是两次 |
仔细想了下,还是觉得不应该重复。 |
可以考虑去掉 all 下周组建一个虚拟项目小组,开始每个组件讨论下,确定修改方案 2014-03-08 18:33 GMT+08:00 army8735 notifications@github.com:
王保平 / 玉伯(射雕) |
Validator 中就有使用 虽少, 但还是有的. |
仔细想并看了代码很久,handler 无所谓同一个还是不同一个。 结论:现在的逻辑貌似没什么问题。 case 1on(a, h1);
on(b, h1);
trigger(a); result:
case 1'on(a, h1);
on(b, h1);
trigger(all); // diff. result:
case 2on(a, h1);
on(all, h1);
trigger(a); result:
case 2‘on(a, h1);
on(all, h1);
trigger(all); result:
|
昨天话题的延伸。
如果有一个callback,同时绑定了某个事件(如a)和all,那么触发a或者all的时候,是否也应该只执行一次?
The text was updated successfully, but these errors were encountered: