Last active
February 27, 2020 13:58
-
-
Save bekapod/0b4da239b2dbafe6098bc1cf447750a8 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const details = { | |
initial: "lookup", | |
states: { | |
lookup: { | |
on: { | |
EMAIL_FOUND: "login", | |
EMAIL_NOT_FOUND: "#checkout.shipping" | |
} | |
}, | |
login: { | |
on: { | |
SUCCESS: "#checkout.shipping", | |
GUEST: "#checkout.shipping" | |
} | |
} | |
} | |
}; | |
const shipping = { | |
on: { | |
COMPLETE: "payment" | |
}, | |
states: { | |
providers: {}, | |
options: {} | |
} | |
}; | |
const payment = { | |
on: { | |
COMPLETE: "confirmation" | |
}, | |
states: { | |
providers: {}, | |
options: {} | |
} | |
}; | |
const confirmation = { | |
type: "final", | |
on: { | |
EDIT_DETAILS: "details", | |
EDIT_SHIPPING: "shipping", | |
EDIT_PAYMENT: "payment" | |
} | |
}; | |
const checkoutMachine = Machine( | |
{ | |
id: "checkout", | |
initial: "details", | |
states: { | |
details, | |
shipping, | |
payment, | |
confirmation | |
} | |
}, | |
{ | |
guards: { | |
isDetailsValid: () => true | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment