| <!DOCTYPE html> |
| <html> |
| <head> |
| <!-- |
| Ought to work in ES.next, if return sugar for |
| generators gets added. |
| --> |
| <script src="../../q.js"></script> |
| <script type="application/javascript;version=1.7"> |
| |
| function test() { |
| |
| var eventuallyFourty = Q.async(function () { |
| var ten = yield 10; |
| console.log(ten, 10); |
| var twenty = yield ten + 10; |
| console.log(twenty, 20); |
| var thirty = yield twenty + 10; |
| console.log(thirty, 30); |
| return thrity + 10; |
| }); |
| |
| Q.when(eventuallyFourty(), function (fourty) { |
| console.log(fourty, 40); |
| }, function (reason) { |
| console.log("error", reason); |
| }); |
| |
| } |
| |
| </script> |
| </head> |
| <body onload="test()"> |
| <div id="box" style="width: 20px; height: 20px; background-color: red;"></div> |
| </body> |
| </html> |