简体   繁体   English

回流错误触发动作

[英]Reflux Error triggering an action

This is either a big bug or I'm having trouble understanding the usefulness of having different view (React) handlers for different actions triggered by the store if all handlers are being called for each of those actions. 这是一个很大的错误,或者我很难理解如果针对每个动作都调用了所有处理程序,则对由商店触发的不同动作使用不同的视图(React)处理程序是否有用。

Here's what I mean: https://jsfiddle.net/69z2wepo/10946/ 这就是我的意思: https : //jsfiddle.net/69z2wepo/10946/

Expected output: 预期产量:

action 1 handler triggered from action 1
-----------------
action 2 handler triggered from action 2

What I actually get: 我实际得到的是:

action 1 handler triggered from action 1
action 2 handler triggered from action 1
-----------------
action 1 handler triggered from action 2
action 2 handler triggered from action 2

Just by looking at this output I can say this is wrong. 仅通过查看此输出,我可以说这是错误的。 But to clarify: action 1 should only trigger the handler for action 1 and action 2 should only trigger the handler for action 2. 但需要澄清的是:动作1仅应触发动作1的处理程序,而动作2应该仅触发动作2的处理程序。

Am I doing something wrong? 难道我做错了什么?

Please help! 请帮忙!

PS: I also tried manually using ComponentDidMount with this.listenTo; PS:我还尝试将ComponentDidMount与this.listenTo;一起使用。 same behaviour. 同样的行为。

Conceptually, I think you have slightly misunderstood Flux. 从概念上讲,我认为您对Flux有误解。 The component doesn't listen for actions/events, it listens for changes in the data in your store. 该组件不监听动作/事件,而是监听商店中数据的更改。 Therefore what you're seeing is correct, since in both cases you are using trigger to indicate that the store has changed. 因此,您所看到的是正确的,因为在两种情况下,您都使用trigger来指示商店已更改。

The component only cares about firing actions, not consuming them. 该组件仅关心触发动作,而不消耗它们。 Therefore labelling onAction1 and onAction2 in the component as "handlers" isn't really correct. 因此,在组件中将onAction1onAction2标记为“处理程序”并不是真正正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM