Skip to content

Commit

Permalink
Add xstate and create first iteration of intersection machine
Browse files Browse the repository at this point in the history
  • Loading branch information
cdonohue committed Jan 12, 2024
1 parent 63985ca commit 1d53121
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
43 changes: 43 additions & 0 deletions machines/intersectionMachine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { createMachine } from 'xstate'

export default createMachine({
id: 'trafficIntersection',
initial: 'allRed',
states: {
allRed: {
after: {
2000: 'northSouthGreen',
},
},
northSouthGreen: {
after: {
5000: 'northSouthYellow',
},
},
northSouthYellow: {
after: {
2000: 'allRedBeforeEastWest',
},
},
allRedBeforeEastWest: {
after: {
1000: 'eastWestGreen',
},
},
eastWestGreen: {
after: {
5000: 'eastWestYellow',
},
},
eastWestYellow: {
after: {
2000: 'allRedBeforeNorthSouth',
},
},
allRedBeforeNorthSouth: {
after: {
1000: 'northSouthGreen',
},
},
},
})
52 changes: 51 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
},
"dependencies": {
"@heroicons/react": "^2.1.1",
"@xstate/react": "^4.0.2",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"xstate": "^5.5.1"
},
"devDependencies": {
"@types/node": "^20",
Expand Down

0 comments on commit 1d53121

Please sign in to comment.