1private firstAction():Promise<any> {
2 return new Promise<any>(
3 (resolve, reject) => { ... }
4 );
5}
6private secondAction():Promise<any> {
7 return new Promise<any>(
8 (resolve, reject) => { ... }
9 );
10}
11execute() {
12 this.firstAction().then(
13 (firstResult:any) => this.secondAction().then(
14 (secondResult:any) => { ... }
15 );
16 )
17}
1new Promise(function(resolve, reject) {
2
3 setTimeout(() => resolve(1), 1000); // (*)
4
5}).then(function(result) { // (**)
6
7 alert(result); // 1
8 return result * 2;
9
10}).then(function(result) { // (***)
11
12 alert(result); // 2
13 return result * 2;
14
15}).then(function(result) {
16
17 alert(result); // 4
18 return result * 2;
19
20});