Rails + React + Redux - Pt 9
In the last post I setup the index.js and App.js files for the project. I also created a file structure to work from as the project grows. Here I'll focus on the actions files, with reducers in the next post.
Let's get started!
The queen_actions.js file holds fetchQueens and updateQueen. For now, I'm not planning on users being able to add or delete a queen.
The trivia_actions.js file is a little more fun. Because trivia (and quotes) must belong to a queen, they add a thin layer of complexity to the interaction with the Rails API. I'm adding the gist for the trivia actions file, but not the quotes file as it is nearly exactly the same.
The season_actions.js file is, for now, only the fetch call. I will eventually need to update this so users can update appearance attributes.
I imagined I'll need a common_actions.js file as the project grows to avoid creating the same function in multiple files.
I created a types.js file to define and export the action constants.
Even at the beginning stages of this project, indexing the actions files was an obvious necessity to avoid massive files.
When I started thinking of actions in a similar way to how I think of controllers in a full-on Rails application, they started to make a little more sense to me. Reducers is where I was really thrown, which I can't wait to get back into next week!
Top comments (0)