Last active
February 5, 2021 06:27
-
-
Save pavankataria/44400f0d8a60d3058892f8fd13e02cea 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 lightMachine = Machine({ | |
// not a parallel machine | |
id: 'parallel', | |
// initial: 'green', | |
// states: { | |
// green: { | |
// on: { TIMER: 'yellow' } | |
// }, | |
// yellow: { | |
// on: { TIMER: 'red' } | |
// }, | |
// // nested parallel machine | |
// red: { | |
type: 'parallel', | |
states: { | |
walkSign: { | |
initial: 'solid', | |
states: { | |
solid: { | |
on: { COUNTDOWN: 'flashing' } | |
}, | |
flashing: { | |
on: { STOP_COUNTDOWN: 'solid' } | |
} | |
} | |
}, | |
pedestrian: { | |
initial: 'walk', | |
states: { | |
walk: { | |
on: { COUNTDOWN: 'wait' } | |
}, | |
wait: { | |
on: { STOP_COUNTDOWN: 'stop' } | |
}, | |
stop: { | |
type: 'final' | |
} | |
} | |
}, | |
beepSound: { | |
initial: 'noSound', | |
states: { | |
noSound: { | |
on: { COUNTDOWN: 'sound' } | |
}, | |
sound: { | |
on: { STOP_COUNTDOWN: 'noSound' } | |
} | |
} | |
} | |
} | |
// } | |
// } | |
}); | |
// const lightMachine = Machine({ | |
// // not a parallel machine | |
// id: 'light', | |
// // initial: 'green', | |
// // states: { | |
// // green: { | |
// // on: { TIMER: 'yellow' } | |
// // }, | |
// // yellow: { | |
// // on: { TIMER: 'red' } | |
// // }, | |
// // // nested parallel machine | |
// // red: { | |
// type: 'parallel', | |
// states: { | |
// walkSign: { | |
// initial: 'solid', | |
// states: { | |
// solid: { | |
// on: { COUNTDOWN: 'flashing' } | |
// }, | |
// flashing: { | |
// on: { STOP_COUNTDOWN: 'solid' } | |
// } | |
// } | |
// }, | |
// pedestrianComponent: { | |
// type: 'parallel', | |
// states: { | |
// pedestrian: { | |
// initial: 'walk', | |
// states: { | |
// walk: { | |
// on: { COUNTDOWN: 'wait' } | |
// }, | |
// wait: { | |
// on: { STOP_COUNTDOWN: 'stop' } | |
// }, | |
// stop: { | |
// type: 'final' | |
// } | |
// } | |
// }, | |
// beepSound: { | |
// initial: 'noSound', | |
// states: { | |
// noSound: { | |
// on: { COUNTDOWN: 'sound' } | |
// }, | |
// sound: { | |
// on: { STOP_COUNTDOWN: 'noSound' } | |
// } | |
// } | |
// } | |
// } | |
// } | |
// } | |
// // } | |
// // } | |
// }); | |
// console.log(lightMachine.transition('yellow', 'TIMER').value); | |
// { | |
// red: { | |
// walkSign: 'solid', | |
// pedestrian: 'walk' | |
// } | |
// } | |
// const lightMachine = Machine({ | |
// // not a parallel machine | |
// id: 'light', | |
// initial: 'green', | |
// states: { | |
// green: { | |
// on: { TIMER: 'yellow' } | |
// }, | |
// yellow: { | |
// on: { TIMER: 'red' } | |
// }, | |
// // nested parallel machine | |
// red: { | |
// initial: 'green', | |
// states: { | |
// green: { | |
// on: { TIMER: 'yellow' } | |
// }, | |
// yellow: { | |
// on: { TIMER: 'red' } | |
// }, | |
// // nested parallel machine | |
// red: { | |
// type: 'parallel', | |
// states: { | |
// walkSign: { | |
// initial: 'solid', | |
// states: { | |
// solid: { | |
// on: { COUNTDOWN: 'flashing' } | |
// }, | |
// flashing: { | |
// on: { STOP_COUNTDOWN: 'solid' } | |
// } | |
// } | |
// }, | |
// pedestrian: { | |
// initial: 'walk', | |
// states: { | |
// walk: { | |
// on: { COUNTDOWN: 'wait' } | |
// }, | |
// wait: { | |
// on: { STOP_COUNTDOWN: 'stop' } | |
// }, | |
// stop: { | |
// type: 'final' | |
// } | |
// } | |
// } | |
// } | |
// } | |
// } | |
// } | |
// } | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment