Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can flux actions access stores?

Tags:

reactjs

flux

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?

like image 417
bigblind Avatar asked Mar 13 '15 03:03

bigblind


Video Answer


1 Answers

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.

like image 146
MFors Avatar answered Sep 30 '22 02:09

MFors