Can Flux actions access stores? I recently got a code review comment asking me to pass a certain value in from a React component, instead of getting it from the store directly in the action. This would change Flux's data flow from this:
View->Action->Dispatcher->Store-|
^-----------------------------<
to this
View->Action->Dispatcher->Store-|
^------^----------------------<
It seems to me that, because all data changes are still going through the dispatcher, that the data flow still goes in the intended direction, updates are still atomic, annd the flow is still easy to reason about. Could there be any drawback?
An action can access a Store, but it should be a strict read-only operation.
Actions may want to yield a dispatch that is conditional on the content of a store and keeping track of what store content is required to perform the action is not the responsibility of the invoking component.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With