Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
async 完全理解 - 全ての async は Promise に通ず / Guide to...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
saiya_moebius
December 04, 2020
Programming
640
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
async 完全理解 - 全ての async は Promise に通ず / Guide to async, await
saiya_moebius
December 04, 2020
More Decks by saiya_moebius
See All by saiya_moebius
エムスリーの Over 300 マイクロサービスを支えるマルチクラウドのネットワーク設計 / M3 cloud network infrastructure for over 1000 microservices
saiya_moebius
0
430
TypeScript の型システム / Type system of the TypeScript
saiya_moebius
10
3.4k
垂直スケールの果ての db.r4.16xlarge で得た教訓 / What happened on vertically scaled 16xlarge DB
saiya_moebius
4
4.3k
DNS を 15 分で雑に知る / grasp DNS in 15 minutes
saiya_moebius
0
210
分散トレーシングの技術選定・OSS 貢献, Stackdriver Trace での性能可視化・改善 / Distributed Tracing case study
saiya_moebius
10
7.2k
RDBMS in Action
saiya_moebius
56
29k
Kubernetes こわくないよ!
saiya_moebius
1
6k
Compiler/JIT optimizations & escape analysis
saiya_moebius
2
520
How to setup Gradle to improve legacy Java system
saiya_moebius
1
3k
Other Decks in Programming
See All in Programming
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
500
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
0
380
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
260
信頼性の目標を誰も求めてない
shubox
0
490
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
600
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
6
2.5k
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
420
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
ソフトウェアラスタライザ
fadis
1
790
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
420
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
510
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
580
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.3k
Transcript
None
None
None
Promise Deferred Objects async await Promise async await
None
Promise<T> ( ) ( ) resolve(T) Promise reject(any) Promise then(f,
f) , ,
Promise<T> ( ) ( ) resolve(T) Promise reject(any) Promise then(f,
f) , ,
async return throw await const value = await ; console.debug(value);
.then((value) => { console.debug(value); });
None
None
None
const promise = new Promise(); // ... ... promise.resolve( );
/* */ promise.reject( ); new Promise((resolve, reject) => { // ... ... resolve( ); /* */ reject( ); });
// Promise let resolve, reject; new Promise((_resolve, _reject) => {
// resolve, reject resolve = _resolve; reject = _reject; }); resolve( ); /* */ reject( ); // ↑ ...
function () { // Promise ... const promise = new
Promise(); // ... ( promise.resolve ) ... return promise; } const promise = (); promise.resolve(null); // resolve
function () { // Promise return new Promise((resolve, reject) =>
{ // ... ( resolve ) ... }); } const promise = (); // ↑ resolve
function (props) { // const hoge = props.something.foobar(); // Promise
... const promise = new Promise(); // ... ( promise.resolve ) ... return promise; } resolve( ) reject( )
None
function () { /* ※1 */ return new Promise((resolve, reject)
=> { // reject( ) }); } const promise = (); // ↑ Promise reject ※1
promise.then .then((result) => { return (); // Promise }).then((result) =>
{ // result === });
Promise.all(Promise<T>[]): Promise<T[]> Promise.race(Promise<T>[]): Promise<T> promise.catch(f)
function myFunction() { A().then((resultA) => { if (resultA === "hoge")
{ B().then((resultB) => { if (resultB === "huga") C(); }); } else { D().then((resultC) => { if (resultC === "piyo") E(); }); } }); }
None
None
async return throw await const value = await ; console.debug(value);
.then((value) => { console.debug(value); });
await // async function myFunction() { if (await A() ===
"hoge") { if (await B() === "huga") C(); } else { if (await D() === "piyo") E(); } } await then
None
Promise Promise.all Promise.race await Promise.all( 1(), 2(), ...) Promise
async await async Promise Promise await await
None
None
async await function hoge() { const async = 1; const
await = 2; console.log(async, await); // it works } async await async function() { ... } async
await async function myFunction() { await 1(); // 1().then(...) 1();
2(); // await 2(); await 3(); // 3().then(...) } 2 no-floating-promises
await Promise.resolve(Promise.resolve(123)); // Promise.resolve(123) 123 // Promise.resolve Promise
fulfill reject resolve Promise.reject(e) Promise.resolve(value) fulfill resolve reject
new Promise Promise. Promise
Promise Promise Promise = undefined; // Promise.resolve(1234); // await (async()
=> 123)(); // async await Promise Promise ZoneAwarePromise Promise Zone async await Promise.
await then await 14.6.13 Runtime Semantics: Evaluation 25.5.5.3 AsyncFunctionAwait (
value ) 25.4.5.3.1 PerformPromiseThen
await