Questions tagged [xstate]

xstate is Javascript library for creating finite state machines and statecharts.

xstate is library for creating finite state machines and statecharts in JavaScript. Code and links to documentation found at https://github.com/davidkpiano/xstate

146 questions
1
vote
1 answer

xstate-how to return from data from interpret(machine).onDone()

I want to return data from onDone(). I have tried reply() function, but it is also not working. server.route({ method: 'POST', path: '/change-state/testing', handler: function (request,h) { return…
1
vote
1 answer

Why this assign does not trigger?

After reading the official xstate tutorial, I tried to implement my own machine inspired by this post on dev.to by one of the xstate's dev. Everything works as expected besides that output does not seem to be updated. The assignment does not do its…
aloisdg
  • 22,270
  • 6
  • 85
  • 105
1
vote
1 answer

Why xstate transition is not working for me in nodejs?

//Customer State Machine const CustomerStateMachine = createMachine( { id: "customer", initial: "pending", states: { pending: { on: { PASSWORD_RESET_COMPLETED: { target: "active", …
Lalit Kolate
  • 31
  • 1
  • 4
1
vote
2 answers

xstate pass event data into onDone from service

I have xstate react script whereby a user fills in a form, and presses submit. On submit the xstate received a send("VALIDATE", {formData}) and that is run through a service that validates the form. On success the script transitions to the target:…
Nathan Leggatt
  • 398
  • 1
  • 6
  • 18
1
vote
1 answer

How can I prevent XState node from resetting it's child parallel states when receiving an event?

I was exploring the XState world and tried to recreate the machine @davidkpiano mentioned in this talk And faced an issue with doing the transitions right. When I send a message to parent machine, it resets all the child machines. For example: I…
Temoncher
  • 644
  • 5
  • 15
1
vote
1 answer

How to track analytics events with xstate

I'm using xstate in my React Native app to manage a rather complex flow. I would like to systematically log analytics events on each state transition and event happening in the state machine. So far, I haven't figured how to do that without manually…
samzmann
  • 2,286
  • 3
  • 20
  • 47
1
vote
1 answer

Xstate Getting warning: No implementation found for action type

I have similar actions ADD_THOUGHT_TIME_STAMP in two different states, so I tried moving that action to the actions of xStat, by fallowing the official documentation. But I keep getting an error: "No implementation found for action type…
user4602966
  • 107
  • 1
  • 10
1
vote
0 answers

In an xState action how can I access the private _state?

The scenario: when onEntry to the submit state it fires a defined saveData action. This action persists the form data, the catch is I can’t get access to the data although if I hardcode a dataset object and use that it works. I can see the data I…
chris loughnane
  • 2,648
  • 4
  • 33
  • 54
1
vote
2 answers

Use external data in XState FSM

I'm trying to shim XState into an existing state management system (in a React app) and I'm trying to figure out how to represent the state that is already captured in the legacy state management without duplication. import {useLegacyState} from…
ABMagil
  • 4,579
  • 4
  • 21
  • 35
1
vote
1 answer

How to give dynamic request to robot?

I just found a finite state module called Robot. it's very lightweight and simple. I got one case I couldn't solve, which is to create a dynamic request for API inside Robot. I tried this robot.js const context = () => ({ data: [], }); export…
principiorum
  • 528
  • 7
  • 21
1
vote
2 answers

how to configure dynamic form fields inside a wizard when using a state machine

I am trying to implement a multi-step wizard using a state machine and am unsure how to handle some configurations. To illustrate this I put together an example of a wizard that helps you prepare a dish. Assuming the following example what would be…
matteok
  • 2,189
  • 3
  • 30
  • 54
1
vote
1 answer

Why xState is not working with react redux?

I am trying to change the status of the button when the user clicks, it's all part of the xstate, where the buttons are getting, according to the State the button is going to work.in typescript, it's working fine but not in react hooks const…
user13647807
1
vote
1 answer

not able to create child states for xstate

I have created this codesandbox to highlight the problem. I have created a state machine for a react hook abortable fetch. The only way I could get it to work was to have all the states at the same level: export interface AbortableSchema { …
dagda1
  • 26,856
  • 59
  • 237
  • 450
1
vote
3 answers

AWS lambda instance shuts down while xstate invoke promise

I have a lambda function that uses xstate to perform certain tasks sequentially and one of the steps is to save data to dynamo db. But my lambda ends execution as soon as the below line is being executed. const response = await new…
1
vote
1 answer

Firebase cloud function not doing anything with Xstate

I'm trying to write a cloud function on Firebase that updates a document in Firebase when another one is written. I use the trigger method onWrite for this. I use Xstate for this, as my original code is more complex, but the idea is the same (and…