Created
May 7, 2020 22:13
-
-
Save davidkpiano/4d4af3842ab7987e0543f695efb8778f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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: 'off', | |
states: { | |
off: { | |
on: { | |
[toggleName]: 'on' | |
} | |
}, | |
on: { | |
on: { | |
[toggleName]: 'off' | |
} | |
}, | |
}, | |
} | |
} | |
const buttons = { | |
id: 'buttons', | |
type: 'parallel', | |
states: { | |
button1: buttonFactory(1), | |
button2: buttonFactory(2), | |
hist: { | |
type: 'history', | |
history: 'deep', | |
}, | |
}, | |
on: { | |
SLEEP: '#idle', | |
} | |
} | |
const parallelTest = Machine({ | |
id: 'test', | |
initial: 'idle', | |
states: { | |
idle: { | |
id: 'idle', | |
on: { | |
START: 'buttons.hist', | |
} | |
}, | |
buttons, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment