Last active
May 8, 2016 22:49
-
-
Save jonjaques/38d2dc971f449d5187addb3e0ae4d5b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think you can
await
inside a loop...