Skip to content

Instantly share code, notes, and snippets.

@benshell
Last active December 6, 2019 19:53
Show Gist options
  • Select an option

  • Save benshell/5413f8f910ed995d29a3a435767b9ba4 to your computer and use it in GitHub Desktop.

Select an option

Save benshell/5413f8f910ed995d29a3a435767b9ba4 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: 'fetch',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
APPROACH: 'intro',
WAVE: 'intro',
GREETING: 'intro'
}
},
intro: {
on: {
RESPONSE: 'donkey',
NO_RESPONSE: 'idle'
}
},
donkey: {
on: {
RESPONSE: 'wonderful',
NO_RESPONSE: 'donkey'
}
},
wonderful: {
on: {
COLOR_DETECTED: 'color'
}
},
color: {
on: {
COLOR_DETECTED: 'color',
HAND_RAISED: 'perfect',
THUMBS_UP: 'perfect',
}
},
perfect: {
on: {
RESPONSE: 'thanks',
NO_RESPONSE: 'hesitated'
}
},
hesitated: {
on: {
RESPONSE: 'thanks',
NO_RESPONSE: 'color'
}
},
thanks: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment