Created
May 7, 2020 20:40
-
-
Save chukinas/90402ec2c1f24eae3a0ca88037f4e21c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buttonFactory = id => { | |
const toggleName = `TOGGLE${id}` | |
return { | |
id: `button${id}`, | |
initial: 'hist', | |
states: { | |
off: { | |
on: { | |
[toggleName]: 'on' | |
} | |
}, | |
on: { | |
on: { | |
[toggleName]: 'off' | |
} | |
}, | |
hist: { | |
type: 'history', | |
target: 'off', | |
history: 'deep', | |
}, | |
}, | |
} | |
} | |
const buttons = { | |
id: 'buttons', | |
type: 'parallel', | |
states: { | |
button1: buttonFactory(1), | |
button2: buttonFactory(2), | |
}, | |
on: { | |
SLEEP: '#idle', | |
} | |
} | |
const parallelTest = Machine({ | |
id: 'test', | |
initial: 'idle', | |
states: { | |
idle: { | |
id: 'idle', | |
on: { | |
START: 'buttons', | |
} | |
}, | |
buttons, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment