function myFunction() {
wait(); //what I put there?
return;
}
myFunction();
//this is an event; when its triggered I want function to resume
onSomething = function() {
myFunction.resume(); //what I put there?
}
Its just a local experience. Note that while(!resume) won't work because that would prevent the event onSomething to happen.
This is not possible.
Instead of waiting for the event, you want to put whatever you need to do when it happens into the
onSomething
function.You have to switch your brains to thinking in events instead of the "traditional" programming flow. The way to do this is:
So, with a generator it would look like so:
Live demo: http://jsfiddle.net/MQ9PT/
This however doesn't work beyond Firefox. It will become part of the ECMAScript standard in the next edition...