This is a great question and one that I have encountered before.
Remember that the most important thing about Flux is that data is transferred one way, always. You already know this - I bring it because one of these statements has many explanatory powers and almost completely answers any question that may arise regarding Flux.
Actions send data to storages, so if you add logic to your actions that check the value of something in your store, you send data in the wrong direction, against the stream.
So, what part of the Flux app gets data from stores? Kinds. There is your answer.
The idea of ββyour views containing caching logic may seem strange, but think about what caching is:
- I need data.
- Do I already have this data? If not...
- Let's go to.
Viewer # 1. This is pretty simple. And No. 3 is obviously being handled by your actions. But it turns out that No. 2, at least in the Flux application, also has something that needs to be considered in your views, or rather, your view controllers. Controller views are often a forgotten part of Flux, probably because the idea of ββcontrollers is so strongly linked to MVC. But Flux has them too! On the Flux website:
Controllers exist in the Flux application, but they are controller views β views that are often found at the top of the hierarchy that retrieve data from storage and pass that data on to their children.
Assuming you are using React, this idea should sound familiar. Higher-level reaction components are -y controllers, and lower-level components are more "pure".
Another way to think about it is to note that actions are simply dispatcher assistants. (If I remember correctly when Facebook first introduced Flux, they didn't even mention the actions.) By the time you called the action, you had already decided to send: the only question is what, not if.
Taking this back, I understand that all this may seem like a difference without differences, but the main conclusion is that no, actions cannot check the state of the store. They can communicate with them only through the dispatcher. You may find a way to make it work in practice (which should not be discounted!), But this is not an idiomatic flow.
Hope this makes sense!