-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry02.html
34 lines (33 loc) · 1.22 KB
/
try02.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
<head>
<title>I promised I will try Q</title>
<script src="./lib/q/q-20130830/q.js"></script>
<script>
var step1 = function () {
console.log("This is step 1, args=", arguments);
return "ret 1";
};
var step2 = function () {
console.log("This is step 2, args=", arguments,
", at this moment promise1.isFulfilled()=", promise1.isFulfilled(),
", at this moment promise2.isFulfilled()=", promise2.isFulfilled()
);
return "ret 2";
};
var step3 = function () {
console.log("This is step 3, args=", arguments,
", at this moment promise1.isFulfilled()=", promise1.isFulfilled(),
", at this moment promise2.isFulfilled()=", promise2.isFulfilled()
);
return "ret 3";
};
var promise1 = Q.fcall(step1);
var promise2 = promise1.then(step2); // promise2 will be fulfilled with the value returned by step1: "ret 1"
var promise3 = promise2.then(step3); // promise3 will be fulfilled with the value returned by step2: "ret 2"
</script>
</head>
<body>
Check console.
</body>
</html>