I use redux to create a small fusball manager. This is basically a page that shows the score of both teams and some buttons to enlarge them. I have actions such as { type:"GOAL_UP", team:"red" }for which the gearbox will change the corresponding value (rating) in the state.
Now I want to add an epic that whenever he encounters GOAL_UP, checks to see if one of the two teams won. If the team has reached 8 points, I want her to send the action GAME_WON. My problem is that I have to get access to the state in order to find out the score of each team. I cannot find a way to access the state from the epic.
Is access to state out of scope for contraction? If so, how would you solve this problem?
I think that a new account as a property in action GOAL_UP. Something like that { type:"GOAL_UP", team:"red", newScore:8 }. But somehow it seems wrong. I also have two physical buttons on the fusball table that are associated with web sockets that send the action GOAL_UP. Since they are not called from my ui, they are not aware of the condition.
I could also think of sending an action GAME_WONto the rendering function of my ui component if the evaluation of each of the commands is 8. But this is even worse :)
Entrance is very welcome, thanks
source
share