Skip to content

Instantly share code, notes, and snippets.

@blake-mealey
Created March 11, 2020 21:30
Show Gist options
  • Save blake-mealey/b4468dba3b43608c5a891041f01e558d to your computer and use it in GitHub Desktop.
Save blake-mealey/b4468dba3b43608c5a891041f01e558d to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine(
{
id: 'startTrial',
initial: 'start',
context: {
email: 'a'
},
states: {
start: {
on: {
'': [
{ target: 'sending', cond: 'hasEmail' },
{ target: 'input' }
]
}
},
input: {
on: {
SEND: 'sending'
}
},
sending: {
on: {
NO_SUBS: 'sent',
SUBS: 'login'
}
},
sent: {
on: {
SEND: 'sending'
}
},
login: {
type: 'final'
}
}
},
{
guards: {
hasEmail: context => !!context.email
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment