Initial import
[darksolar] / node_modules / q / examples / async-generators / 3-wishful-thinking.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4     <!--
5         Ought to work in ES.next, if return sugar for
6         generators gets added.
7     -->
8     <script src="../../q.js"></script>
9     <script type="application/javascript;version=1.7">
10
11         function test() {
12
13             var eventuallyFourty = Q.async(function () {
14                 var ten = yield 10;
15                 console.log(ten, 10);
16                 var twenty = yield ten + 10;
17                 console.log(twenty, 20);
18                 var thirty = yield twenty + 10;
19                 console.log(thirty, 30);
20                 return thrity + 10;
21             });
22
23             Q.when(eventuallyFourty(), function (forty) {
24                 console.log(forty, 40);
25             }, function (reason) {
26                 console.log("error", reason);
27             });
28
29         }
30
31     </script> 
32     </head>
33     <body onload="test()">
34         <div id="box" style="width: 20px; height: 20px; background-color: red;"></div>
35     </body>
36 </html>