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?
}
它只是一个地方的经验。请注意,虽然(!resume)不起作用,因为这会阻止事件发生。在返回之前做一个等待事件的函数?
你可以使用[generators](https://developer.mozilla.org/en/JavaScript/Guide/Iterators_and_Generators)来做到这一点,但这不是交叉-browser。它将与ECMAScript 6来...虽然... –