Last active
April 10, 2019 20:41
-
-
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/
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
// 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