Search code examples
reactive-programmingflux

Regarding flux conventions, why a single file per action?


I've noticed that a lot of the sample flux projects follow the convention of a single file per action rather than grouping them together. What is the reason for that, is that a strong convetion?

My preference is to group related actions together into single files, e.g. wishlistActions.js would include, create, addProduct, removeProduct, and delete.

Does that go against the grain? If so, why?


Solution

  • I don't think that goes against the grain and I don't know if Flux prescribes any singular way to do that.

    In fact, Ryan Florence (one of the authors of react-router) has a demo repo where he has a Constants.js file listing all his actions. And then he has individual actionCreator classes.

    https://github.com/FrontendMasters/2015-02-13-React/tree/master/excercises/5-flux/app