Skip to content

Instantly share code, notes, and snippets.

@heypoom
Created July 4, 2019 08:06
Show Gist options
  • Save heypoom/a697b167f9bbe388613cd58a9225ce41 to your computer and use it in GitHub Desktop.
Save heypoom/a697b167f9bbe388613cd58a9225ce41 to your computer and use it in GitHub Desktop.
const urinal = Machine({
id: 'urinal',
initial: 'inactive',
states: {
inactive: {
on: {
OBJECT_FOUND: 'rinsing'
}
},
// rinse for 2 seconds, then off.
rinsing: {
on: {
RINSE_COMPLETE: 'detecting'
}
},
// When the object is gone, do the cleanup rinsing.
detecting: {
on: {
OBJECT_GONE: 'cleanup_rinsing',
OBJECT_FOUND: 'rinsing'
}
},
// Rinse for 5 seconds then turn off
cleanup_rinsing: {
on: {
RINSE_COMPLETE: 'inactive'
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment