Created
June 4, 2020 08:47
-
-
Save tom-sherman/8ede96411bf8d4a41a3cc83b31bb8a11 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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 saleStatusMachine = Machine({ | |
id: 'saleSatus', | |
initial: 'in_progress', | |
states: { | |
in_progress: { | |
on: { | |
HOLD: 'held', | |
COMPLETE: { | |
target: 'completed', | |
cond: 'isFullyPaid' | |
}, | |
PAY: { | |
target: 'in_progress', | |
actions: 'makePayment' | |
}, | |
} | |
}, | |
held: { | |
on: { | |
UNHOLD: 'in_progress' | |
} | |
}, | |
completed: { | |
type: 'final' | |
}, | |
} | |
}, | |
{ | |
actions: { | |
makePayment: (type, amount) => console.log('todo: implementation') | |
}, | |
guards: { | |
isFullyPaid: () => true | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment