Replies: 1 comment 1 reply
-
|
After watching https://www.youtube.com/watch?v=NVE77_axR6s I've been thinking about it in the wrong way |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working with XState in the backend for managing some complex state flows.
Everytime an operation is requested by the client, like
withdrawingoradding infoto acase, I'm fetching thecasefrom the database and initializing based on the current state using:In the controller, I then send an event to the actor and wait for a certain state to be reached.
This setup seems to work nicely.
My concern is when to persist a new state to the database.
For example, we have a state transition from
waiting -> withdrawnbased on the eventwithdraw.However, I only want to go to the state 'withdrawn' after updating the state in the database. I cannot use an action for this because it's async. My current solution is to have an intermediate state
withdrawingin which I invoke an actor that persists the state. UsingonDonewe'll then transition towithdrawn. However, this solution feels rather clumsy because now we have to create such an intermediate state for every transition in the FSM.Is there a better way to solve this?
Beta Was this translation helpful? Give feedback.
All reactions