Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Xstate for backend entity state management?#4200

Unanswered
sksethi25 asked this question inQ&A
Discussion options

Can we use Xstate at backend/server side for state management of an entity

Example: Suppose to build a product like Jira where Issue entity can be moved in various status.

Sample Jira Issue flow
jira

is it feasible and efficient to achieve something like following with Xstate
Deploying Xstate Machine with Node/exrpess.js backed API that creates Issue (Suppose issue in created state) in its initial state and init the Xstate machine and then an API for giving various next Events possible (move to in progress from created state) and another API to initiate that event to make transition to next state( like moving to in progress from qa).

Please guide further if anyone done something like this or any other apporach?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Hey@sksethi25!

Yes, you can definitely do this. The process would look like this for a serverless function:

  1. Read state from storage, if it exists.
    • If it doesn't exist, use the machine's initial state
  2. Start the machine from the persisted (or initial) state
  3. Send the machine the event from therequest
  4. Read the next state viaactor.getSnapshot() and persist it to storage
  5. Send a response (e.g. 200 OK)

I will make an example of this soon.

You must be logged in to vote
1 reply
@ashubhadoria
Comment options

I am late to the party, but is there any chance,@davidkpiano, that there is some sample code for modelling this?
I have a similar use case where I need to read from a persisted storage, read the state, perform an action, and store back to that persisted storage.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@sksethi25@davidkpiano@ashubhadoria

[8]ページ先頭

©2009-2025 Movatter.jp