Created
May 28, 2021 21:54
-
-
Save davidkpiano/6f46cc8f14e560a8e9fea2c21a9f3b86 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 machine = Machine({ | |
id: 'ATM', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
INSERT_CARD: 'authenticating', | |
} | |
}, | |
authenticating: { | |
on: { | |
CANCEL: 'ejectingCard', | |
ERROR: 'ejectingCard' | |
}, | |
initial: 'readingCard', | |
states: { | |
readingCard: { | |
on: { | |
ACCEPT_CARD: 'askingForPIN', | |
REJECT_CARD: { | |
actions: raise('ERROR') | |
}, | |
} | |
}, | |
askingForPIN: { | |
on: { | |
ENTER_PIN: 'checkingPIN' | |
} | |
}, | |
checkingPIN: { | |
on: { | |
ACCEPT_PIN: '#ATM.banking', | |
REJECT_PIN: 'askingForPIN', | |
} | |
}, | |
}, | |
}, | |
banking: { | |
on: { | |
CANCEL: 'ejectingCard', | |
}, | |
initial: 'choosingTransaction', | |
states: { | |
choosingTransaction: { | |
on: { | |
CONFIRM_TRANSACTION: 'performingTransaction', | |
} | |
}, | |
performingTransaction: { | |
after: { | |
2000: 'choosingTransaction', | |
} | |
}, | |
}, | |
}, | |
ejectingCard: { | |
after: { | |
2000: '#ATM.idle', | |
} | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment