Reflux Error triggering an action

100 views Asked by At

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.

Here's what I mean: 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.

Am I doing something wrong?

Please help!

P.S: I also tried manually using ComponentDidMount with this.listenTo; same behaviour.

1

There are 1 answers

0
Colin Ramsay On

Conceptually, I think you have slightly misunderstood 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.

The component only cares about firing actions, not consuming them. Therefore labelling onAction1 and onAction2 in the component as "handlers" isn't really correct.