Statecharts for Redux

312 Views Asked by At

Current State Management Stack: React, RTK/Redux, and Redux-Saga

Here's the high level issue. We have a complex flow and we don't have QA Engineering resources to be able to write the integration tests needed for this. This leads to the following issues:

  • A lot of context needed to change something in this flow(without introducing bugs)
  • Having to manually test a lot of different paths in the flow to try and make sure nothing was broken
  • A huge lack of efficiency
  • Even with dedicated QA effort, bugs still slip through to production with how many paths there are

I've been looking at xstate and really love the ability to generate statecharts(less context needed, non-technical stakeholder understanding, & seems like it would result in better efficiency moving forward). For state management, we currently use Redux across the platform(changing this would be incredibly out of scope). This leads me to my questions:

  • Does anyone know of a (well supported)npm package where I can integrate Redux with statecharts?
  • If not, what are the pros/cons of implementing both xstate and Redux? Xstate would only be for this flow and would need to pull some data from Redux. While Redux state is available to xstate, I'm assuming I wouldn't need to write it in a way that Redux is dependent on xstate.

I'm not super familiar with xstate but I don't want to dive too deep if this ends up being a waste of time/terrible idea.

ALSO - for context, this is a very large repo & the solution needs to be maintainable, readable, and most importantly - scalable

ALSO 2 - The main goal of this is the auto-generated statecharts. We have many hands in this flow and keeping documentation up to date manually is not feasible

1

There are 1 best solutions below

0
markerikson On

You can always use statecharts as Redux reducer functions! In fact, one of the XState devs put together an example repo demonstrating exactly how to do that (as well as using XState services in a Redux middleware for side effects):

https://github.com/mattpocock/redux-xstate-poc