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
0
votes
1 answer

React Xstate spawn machine with machine options

Is there any way to pass machine options such as "guards" and "delays" to a spawned machine either through the "spawn" function on the parent machine or the "useActor" hook on the context property?
DiniMad
  • 49
  • 1
  • 9
0
votes
2 answers

Executing an action in every state

I want to execute an action in every state's entry. How can I do that? It can be done like this: const promiseMachine = createMachine({ id: "promise", initial: "pending", states: { pending: { entry: ["myAction"] }, resolved:…
user9408899
  • 4,202
  • 3
  • 19
  • 32
0
votes
1 answer

XState sending event to child machine from external function

I have an external function called onMessageUpdated I need to send events from that function to a child state machine. Here's how I'm binding that function already in invoked service: states: { createThread: { invoke: { src:…
Gezim
  • 7,112
  • 10
  • 62
  • 98
0
votes
1 answer

set initial x state value by variable?

When using x state app machine. How do I set the initial state to a variable? I want the intial state to be either full screen or menu, when the boolean value is sent from another file. I want to send a boolean value from some page to the app…
lache
  • 608
  • 2
  • 12
  • 29
0
votes
0 answers

Cannot perform 'get' on a proxy that has been revoked

export const bulkWatchPayload = (requestIds = [], currentView) => { const structuredData = requestIds.map( (requestId) => `ukca_${requestId}_${currentView}` ) return { userId: getCurrentUserEmailId(), correlationId, …
C09-G
  • 21
  • 4
0
votes
1 answer

Calling parent action from child state machine using XState

VS Code warning: cancelRetry is never used in the machine definition My machine: const authMachine = createMachine( { id: "authenticationMachine", tsTypes: {} as import("./consumer.typegen").Typegen0, initial: "newPage", …
Gezim
  • 7,112
  • 10
  • 62
  • 98
0
votes
0 answers

Xstate testing entry action of a state

I have this machine with these 2 states: ... 'Pin entry': { tags: 'drawing', description: '', entry: [ // eslint-disable-next-line xstate/no-inline-implementation () => logger.info('pinChangeFSM', 'Pin entry state drawTemplate'), …
Fobi
  • 435
  • 1
  • 7
  • 17
0
votes
1 answer

Testing Guards in Xstate with Angular

I want to test the guards in the XState Machine { guards: { isSomething: context => meetsConditionsForSomething(context), isSomethingElse: context => meetsConditionsForSomethingElse(context) } } I want to…
emst
  • 1
  • 2
0
votes
0 answers

How to get Routing information and render elements conditionally using Xstate state machine?

I'm using Angular + Typescript. I would like to learn Xstate and am using a simple example. I have three components Header, Home and Summary. Header

This is the header

Home with '/'…
Harvey
  • 93
  • 1
  • 7
0
votes
1 answer

Xstate machine - Load feature flags

What we need to do: We need to feature flag a few things in our current state machine My ideal solution: Always load, no matter what state is, all feature flags and assign them to the state machine context Attempts: Tried using async actions and…
0
votes
0 answers

xstate: Promises: how to detect network error and exit state

I have an xstate state machine in javascript. I invoke a promise on entering a state and show a spinning wheel while the promise is being resolved. I would like to detect network error and send a NETWORK_ERROR event to my state machine. How do I do…
SoftwareDveloper
  • 559
  • 1
  • 5
  • 18
0
votes
1 answer

xstate: type: final: go back to initial/idle state

I have an xstate state machine with 3 states. When data is fetched and final state isreached, the state machine is 'Done'. I would like to go back to initial state of idle after 'finally completing the task'. How do I accomplish that? For…
SoftwareDveloper
  • 559
  • 1
  • 5
  • 18
0
votes
1 answer

Resolving Multiple Promises with Parallel state (XState)

I have an xstate state machine that has 3 states, idle, waitingForA and waitingForB. waitingForB, in turn is a type of parallel state. I would like to return to initial state of 'idle' on waitingForB is done. How do I accomplish this? idle: { id:…
0
votes
1 answer

JavaScript: xstate: DevExpress: show loading panel

I have an ajax call that fetches data and I have an xstate state machine that invokes this ajax call. I would like to show a spinning wheel(DevExpress loading panel) while data is being fetched. How do I show this loading panel? function…
SoftwareDveloper
  • 559
  • 1
  • 5
  • 18
0
votes
0 answers

Using XState in Nuxt 3 with asynchronous functions

I am using XState as a state manager for a website I build in Nuxt 3. Upon loading some states I am using some asynchronous functions outside of the state manager. This looks something like this: import { createMachine, assign } from "xstate" //…
rajohs
  • 237
  • 1
  • 6