Can I use xstate to model an app where the state is determined by the database? #4887
Unanswered
katangafor
asked this question in
Q&A
Replies: 1 comment
-
This sounds like a great use-case! You can use persistence (docs) to read the state and figure out what to do next. There are some examples that show how this can work in e.g. serverless functions, instead of needing to be in-memory. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I work on an app that has a bunch of state logic, but it's not well-defined.
The "state" is really all in the database, strewn about across different tables. It's mostly stuff like "if this value is null, then some step needs to happen next." Or "if this row in table A has a foreign key to a row in table B, it needs to processed, unless the row in table B has a job ID".
The app mostly consists of little-ish functions that look for certain conditions (like the vague ones I've described above), and either pull new data or assign ID's to existing data based on the state of the database. I drew this process out as a state machine in stately studio, which was super helpful. But I'm not sure if I can really use the generated xstate code, because this state machine isn't running in-memory.
Is this really a use-case of state machines? And xstate in particular?
Beta Was this translation helpful? Give feedback.
All reactions