Skip to content

Instantly share code, notes, and snippets.

@a-type
Last active June 26, 2020 03:15
Show Gist options
  • Save a-type/83e4997889c895d383db382e54af462c to your computer and use it in GitHub Desktop.
Save a-type/83e4997889c895d383db382e54af462c 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 displayMachine = Machine({
id: 'display',
initial: 'clock',
context: {
},
states: {
clock: {
on: {
MAIN_BUTTON: 'menu'
}
},
menu: {
states: {
lights: {
on: {
MAIN_BUTTON: '#display.lightsSettings',
DIAL_INCREMENT: 'nest',
DIAL_DECREMENT: 'alarm'
}
},
nest: {
on: {
MAIN_BUTTON: '#display.nestSettings',
DIAL_INCREMENT: 'alarm',
DIAL_DECREMENT: 'lights'
}
},
alarm: {
on: {
MAIN_BUTTON: '#display.alarmSettings',
DIAL_INCREMENT: 'lights',
DIAL_DECREMENT: 'nest'
}
}
}
},
lightsSettings: {
on: {
MAIN_BUTTON: 'menu'
}
},
nestSettings: {
on: {
MAIN_BUTTON: 'menu'
}
},
alarmSettings: {
on: {
MAIN_BUTTON: 'menu'
}
},
alarmRinging: {
on: {
MAIN_BUTTON: 'morningRoutine'
}
},
morningRoutine: {
states: {
showWeather: {
after: {
5000: 'clock'
},
on: {
MAIN_BUTTON: '#display.clock'
}
}
}
}
},
on: {
ACTIVITY_IDLE: {
target: 'clock',
cond: (_, __, meta) => meta.state !== 'alarmRinging',
},
ALARM_TRIGGERED: {
target: 'alarmRinging'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment