Redux With Phaser?

Hey everyone,

This is my first non “halp-plz-I’m-stuck” post!

I am wondering if anyone else is use Redux in their phaser games or if there is some built-in alternative?

I have used Redux a lot in React projects and also Angular (Ngrx). I find it to be really nice for keeping track of the “overall application state” in some place that is outside of all your components (or in the case of phaser, outside of your scenes). This makes it really straightforward to share data between scenes.

I also like the pattern of firing actions that are handled by reducers which return a new state as opposed to say, a mutable object that everything can read from/ write to because with Redux, when the state changes, you know what changed it.

This process of finding out what changed it is made even easier with the redux-devtools chrome extension that I have been using.

Here is an example of how am I using redux in my latest game, most of the reduxy code is in this “global-state” folder.

Here’s an example of how I listen for state changes inside a scene:

And here’s an example of how I send actions from a scene which then leads to the state being changed.

So, I am just wondering what people think about this and if anyone else likes using Redux (or some alternative) to manage the overall state and share data between scenes. :heart: