Skip to content

Instantly share code, notes, and snippets.

@jonjaques
Last active May 8, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonjaques/38d2dc971f449d5187addb3e0ae4d5b8 to your computer and use it in GitHub Desktop.
Save jonjaques/38d2dc971f449d5187addb3e0ae4d5b8 to your computer and use it in GitHub Desktop.
const Jon = new Person('Jon')
const mug = new Mug()
const pot = new Pot()
// It never ends...
(async function typicalDay() {
while (Jon.isAwake) {
if (Jon.energy < 110) {
if (mug.empty) {
if (pot.fresh) {
pot.pourInto(mug)
}
if (pot.empty) {
let coffee = new Coffee()
await pot.brew(coffee)
}
}
Jon.drinkFrom(mug)
}
}
await Jon.sleep(4)
return typicalDay()
})()
@jonjaques
Copy link
Author

I don't think you can await inside a loop...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment