Skip to content

Instantly share code, notes, and snippets.

@forresto
Last active April 10, 2019 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forresto/4a4fb62b7721ddb50aaa4ca894f2bf9a to your computer and use it in GitHub Desktop.
Save forresto/4a4fb62b7721ddb50aaa4ca894f2bf9a to your computer and use it in GitHub Desktop.
a state chart exploration for a webflow component: https://geo-components.webflow.io/#component-geo-get-current-position ... paste gist into https://statecharts.github.io/xstate-viz/
// Available variables:
// Machine (machine factory function)
// XState (all XState exports)
const {sendParent} = XState.actions
const geoMachine = Machine({
id: "geolocation",
initial: "check_geolocation_api",
states: {
check_geolocation_api: {
on: {
YES: "check_https",
NO: "browser_not_supported"
}
},
browser_not_supported: {},
check_https: {
on: { YES: "ready", NO: "needs_https" }
},
needs_https: {},
ready: {
on: { TAP: "getting" }
},
getting:{
on: { SUCCESS: 'success', ERROR: 'fail'}
},
success: {
onEntry: sendParent('COORDS', {}),
on: { TAP: "getting" }
},
fail: {
on: { TAP: "getting" }
},
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment