Who is responsible to fetch data from server in a flux app with caching?

对着背影说爱祢 提交于 2019-12-04 05:27:29

I usually have my store dealing with fetching data. Doing it this way make sure that all the logic can be managed by the store itself, and you have total control on when/how/why you fetch data.

The fact that you can also have stores communicating with each other is also another pro for why the stores should be in charge of handling/fetching data.

Also, as the Flux pattern describes: "Stores contain the application state and logic. Their role is somewhat similar to a model in a traditional MVC, but they manage the state of many objects.." It does make sense to have the stores managing the fetching of data from APIs/server-side.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!