I am trying to wrap my head around Flux, and I actually got a contrived example working, but I'm a bit confused about the event flow. Let's say I define an action called TestAction. My view has an onClick that emits that event;
Dispatcher.dispatch(new TestAction(this.state.currentValue));
Great, it flows down to the store. So far, so good, I get it.
Now, my store does whatever magic it does, talks to servers, etc. and updates itself. Then, for some reason, all examples show the store doing something along these lines;
Dispatcher.register((action: Action) => {
if (action instanceof TestAction) {
var text = (<TestAction>action).text;
console.log('Store got: ', text);
this._text = text + '_';
this.emit(TestStore.TEST_EVENT, this._text);
}
});
So I guess my question is, why is it firing the very same event? Is it specifically for the dispatcher to handle waitFor? Does it inherently understand what it means for the same event to come back?