すいません。
教えてください。
await/asyncを利用して順番に処理が行われるようにしたいです。
しかし、どうやっても非同期処理となり処理結果がバラバラで返ってきます…。
どのようにすれば同期処理として実行する事が出来るのでしょうか?
■ デモ環境
https://stackblitz.com/edit/angular-x2efpo?file=src/app/app.component.ts
■ 実際のソース
TypeScript
1 main = async () => { 2 await this.one() 3 await this.two() 4 await this.three() 5 } 6 7 push() { 8 this.main(); 9 } 10 11 one() { 12 setTimeout(() => { 13 console.log('1つめの処理') 14 }, 1000) 15 } 16 17 two() { 18 console.log('2つめの処理') 19 } 20 21 three() { 22 setTimeout(() => { 23 console.log('3つめの処理') 24 }, 1000) 25 }

回答2件
あなたの回答
tips
プレビュー