stateDiagram-v2
state "form input
entry: a, b" as form%20input
state form%20input {
state "active
entry: enableInput
exit: blah blah" as machine.active
state "disabled
entry: disableInput
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
// Test tree with contrived data | |
let testTree = { | |
value: 1, | |
child: [ | |
{value: 2, child: [ | |
{value: 7, child: []}, | |
{value: 8, child: []}, | |
{value: 9, child: []}, | |
]}, | |
{value: 3, child: []}, |
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
import { createMachine, assign } from "xstate" | |
import { | |
zipCodeRegex, | |
verifyZipcode, | |
formatPhoneNumber, | |
validatePhoneNumber, | |
} from "../../utils/quiz_form_validation" | |
// | |
export const stepMachine = createMachine( |
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
Machine({ | |
initial: 'a', | |
// leaving a syntax error deliberately here | |
states: | |
a: {} | |
} | |
}) |
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 fileMachine = Machine({ | |
id: "file", | |
type: "parallel", | |
states: { | |
upload: { | |
initial: "idle", | |
states: { | |
idle: { |
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 fileMachine = Machine({ | |
id: "file", | |
type: "parallel", | |
states: { | |
upload: { | |
initial: "idle", | |
states: { | |
idle: { |
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 editorPanelMachine = Machine({ | |
context: {immediateUpdate: true}, | |
initial: 'booting', | |
states: { | |
booting: {}, | |
active: {}, | |
updating: { | |
entry: send('UPDATE_MACHINE_PRESSED'), | |
always: 'active', | |
}, |
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
Machine({ | |
initial: 'a', | |
context: {}, // enable this for the machine to work | |
states: { | |
a: { | |
entry: assign({id: 1}), | |
on: { | |
'': [ | |
{target: 'with_id', cond: ctx => !!ctx.id}, | |
'no_id' |
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
Machine({ | |
id: 'a', | |
initial: 'checking_url', | |
context: {gistID: null, gistRawContent: null}, | |
states: { | |
checking_url: { | |
entry: 'parseQueries', | |
always: [ | |
{ target: 'with_gist', cond: 'isGistIDAvailable' }, | |
{ target: 'no_gist' } |
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
Machine({ | |
id: 'test', | |
initial: 'a', | |
states: {a: { | |
entry: ['t'] | |
}} | |
}, { | |
actions: { | |
t: () => console.log('hello') | |
} |
NewerOlder