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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
730
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
180
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
620
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
390
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
210
Flow は今どうなっているか
mizdra
PRO
0
720
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
260
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
580
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
380
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
480
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
620
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
Code Review Best Practice
trishagee
74
20k
Thoughts on Productivity
jonyablonski
76
5.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Discover your Explorer Soul
emna__ayadi
2
1.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