Last active
August 24, 2020 20:20
-
-
Save EvanLovely/a5ce36b59a6bef29e52b55dcae4e0138 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 siteMachine = Machine( | |
{ | |
id: 'site', | |
initial: 'initial', | |
context: { | |
retries: 0, | |
}, | |
states: { | |
initial: { | |
type: 'atomic', | |
on: { | |
SELECT_SITE: 'loadingSite', | |
}, | |
}, | |
loadingSite: { | |
on: { | |
SUCCESS: 'siteLoaded', | |
NO_SITE: 'siteDoesNotExist', | |
THIS_USER_CANNOT_ACCESS: 'showRequestAccess', | |
ANON_USER_CANNOT_ACCESS: 'showUserSignIn', | |
}, | |
}, | |
siteDoesNotExist: { | |
}, | |
showUserSignIn: { | |
on: { | |
SIGN_IN: 'loadingSite' | |
} | |
}, | |
showRequestAccess: {}, | |
siteLoaded: { | |
on: { | |
SELECT_INSTANCE: 'loadingSiteInstance', | |
SWITCH_SITE: 'loadingSite', | |
} | |
}, | |
loadingSiteInstance: { | |
on: { | |
FAILURE: 'loadingSiteInstanceFailure', | |
NOT_FOUND: 'siteInstanceNotFound', | |
SUCCESS: 'siteInstanceLoaded', | |
}, | |
}, | |
siteInstanceNotFound: { | |
on: { | |
SELECT_INSTANCE: 'loadingSiteInstance', | |
SWITCH_SITE: 'loadingSite', | |
} | |
}, | |
loadingSiteInstanceFailure: { | |
on: { | |
RETRY: { | |
target: 'loadingSiteInstance', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1, | |
}), | |
}, | |
}, | |
}, | |
loadingSiteInstanceDeployment: { | |
on: { | |
UNRESPONSIVE: 'siteInstanceDeploymentUnresponsive', | |
SUCCESS: 'siteInstanceLoaded' | |
} | |
}, | |
siteInstanceDeploymentUnresponsive: { | |
on: { | |
RETRY: { | |
target: 'loadingSiteInstanceDeployment' | |
} | |
} | |
}, | |
siteNeedsAuth: { | |
on: { | |
RETRY: { | |
target: 'loadingSiteInstance', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1, | |
}), | |
}, | |
}, | |
}, | |
siteInstanceLoaded: { | |
on: { | |
UNLOAD: 'initial', | |
LOAD_SITE_INSTANCE: 'loadingSiteInstance', | |
}, | |
}, | |
}, | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment