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
saiya_moebius
December 04, 2020
Programming
1
520
async 完全理解 - 全ての async は Promise に通ず / Guide to async, await
saiya_moebius
December 04, 2020
Tweet
Share
More Decks by saiya_moebius
See All by saiya_moebius
エムスリーの Over 300 マイクロサービスを支えるマルチクラウドのネットワーク設計 / M3 cloud network infrastructure for over 1000 microservices
saiya_moebius
0
320
TypeScript の型システム / Type system of the TypeScript
saiya_moebius
10
3.2k
垂直スケールの果ての db.r4.16xlarge で得た教訓 / What happened on vertically scaled 16xlarge DB
saiya_moebius
4
4k
DNS を 15 分で雑に知る / grasp DNS in 15 minutes
saiya_moebius
0
140
分散トレーシングの技術選定・OSS 貢献, Stackdriver Trace での性能可視化・改善 / Distributed Tracing case study
saiya_moebius
10
6.6k
RDBMS in Action
saiya_moebius
56
25k
Kubernetes こわくないよ!
saiya_moebius
1
5.7k
Compiler/JIT optimizations & escape analysis
saiya_moebius
2
400
How to setup Gradle to improve legacy Java system
saiya_moebius
1
2.7k
Other Decks in Programming
See All in Programming
Lambda(Python)の リファクタリングが好きなんです
komakichi
3
200
Agentic Applications with Symfony
el_stoffel
2
300
大LLM時代にこの先生きのこるには-ITエンジニア編
fumiyakume
7
3k
Strategic Design (DDD)for the Frontend @DDD Meetup Stuttgart
manfredsteyer
PRO
0
140
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
160
Dissecting and Reconstructing Ruby Syntactic Structures
ydah
0
660
Building a macOS screen saver with Kotlin (Android Makers 2025)
zsmb
1
150
「”誤った使い方をすることが困難”な設計」で良いコードの基礎を固めよう / phpcon-odawara-2025
taniguhey
0
140
ミリしらMCP勉強会
watany
4
760
5年間継続して開発した自作OSSの記録
bebeji_nappa
0
210
Fiber Scheduler vs. General-Purpose Parallel Client
hayaokimura
1
100
Memory API : Patterns, Performance et Cas d'Utilisation
josepaumard
0
130
Featured
See All Featured
Navigating Team Friction
lara
184
15k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Documentation Writing (for coders)
carmenintech
69
4.7k
Product Roadmaps are Hard
iamctodd
PRO
52
11k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Designing for humans not robots
tammielis
252
25k
The Cult of Friendly URLs
andyhume
78
6.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
550
How STYLIGHT went responsive
nonsquared
99
5.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
390
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