Skip to content

Instantly share code, notes, and snippets.

@boertel
Last active January 7, 2020 18:13
Show Gist options
  • Save boertel/652fbaf76bdb1029accb7ec70b81d17f to your computer and use it in GitHub Desktop.
Save boertel/652fbaf76bdb1029accb7ec70b81d17f to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
id: 'gvg',
type: 'parallel',
states: {
art: {
initial: 'green',
states: {
green: {
after: {
2000: 'red',
}
},
red: {
after: {
2000: 'blue'
}
},
blue: {
after: {
2000: 'green',
}
},
black: {}
}
},
app: {
initial: 'hidden',
states: {
hidden: {
on: {
TAP: 'bottom'
}
},
bottom: {
after: {
2000: 'hidden'
},
on: {
HIDE: 'hidden',
OPEN: 'full',
}
},
full: {
on: {
HIDE: 'hidden'
}
},
sleep: {
initial: 'waiting',
states: {
waiting: {
after: {
5000: 'sleeping',
},
on: {
SLEEPING: 'sleeping',
}
},
sleeping: {}
}
},
settings: {},
}
}
},
on: {
SLEEP: {
target: ['.app.sleep', '.art.black']
},
SETTINGS: {
target: ['.app.settings', '.art.black']
},
CLOSE: {
target: ['.art.green', 'app.hidden']
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment