General statechart chat (https://statecharts.dev / https://github.com/statecharts/statecharts/discussions) — for XState Q&A → https://github.com/davidkpiano/xstate/discussions
pure()
to ensure correct action orderassign
; you can NPM install the next
branch from GitHub locally: https://remarkablemark.org/blog/2016/09/19/npm-install-from-github/
Hi,
Playing with XState actions+guards.....
From my experiments today, an action
wont get executed if its guard
evaluates to false
The docs don't refer to such use-case
Anyone experienced the same? or different?
"processResults": {
"on": {
"Result": [
{
"internal": true,
"actions": "updateCounter",
"cond": {
"type": "someGuard"
}
}
]
}
}
"processResults": {
"on": {
"Result": {
"internal": true,
"actions": [
"updateCounter",
{
"type": "xstate.send",
"event": {
"type": "checkCounter"
}
}
]
},
"checkCounter": [
{
"target": "success",
"cond": {
"type": "someGuard <=== This transition will get selected if this condition passes (after the updateCounter took place)
}
},
{
"internal": true <=== This transition will get selected if the above someGuard will return false.
}
]
}
},
.stop()
method..withContext(...)
, but probably again a bignner problem - couldn't figure out how to make it start out in one or multiple states (in case its a parallel machine or something)Felt challenged by a tweet from @davidkpiano. https://twitter.com/DavidKPiano/status/1374752085938466816
A circuit breaker machine https://stackblitz.com/edit/circuit-breaker — any feedback will be appreciated.
In case someone is interested, I decoupled first version of Visualiser into npm-package
Is there a standard pattern for actors who have a dependency on data managed by another actor?
Let's say I have a CheckoutMachine
and a CartMachine
, and the CheckoutMachine
needs to create or update a payment intent any time the items change in the cart.
Which of these is more idiomatic?
CartMachine
event to fetch/update the payment intentHi all, I was impressed once again with the simplicity and yet powerful concepts of statecharts. I was able to really improve my code with the concepts together with the reducer hook.
I was wondering if anyone knows articles/papers comparing statecharts to category theory it seems to me that statescharts and the actor model can be expressed as categories (or not, idk). But if you know any articles related to that please do share. Thanks.
hey guys. Been struggling to model a kid's video game with state machines. So... the screen is populated with dots. The user is asked to perform various commands that changes the game state. (Ex: Shake the screen, press a green dot, etc).
For simplicity, there's the (1) "Press a X color dot" command, (2) the "Rotate the screen" command, and (3) the "Shake the screen" command.
The game can go to (1) if a dot of the given color exists and if the screen hasn't been rotated. When the user presses the given colored dot, it will add a random colored dot. (2) occurs as long as the screen isn't already rotated. A rotation undoes a shake. (3) Shaking the screen undoes a rotation. We care about this because the command shown to the user is one of "Shake the screen" or "Shake the screen again".
So part of the problem is that as you can see the commands are tightly coupled. If I add another one, the chance of adding a bug is fairly high. So I'm struggling to model the game state correctly with state machines.
`<onentry>
<send event="autoLock" delay="5s" id="idleTimer"/>
</onentry>