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
いまさら振り返るPromise
Search
chikoski
July 23, 2017
Technology
1
510
いまさら振り返るPromise
chikoski
July 23, 2017
Tweet
Share
More Decks by chikoski
See All by chikoski
20210825_ossx
chikoski
0
270
festudy02-wasm
chikoski
1
940
An overview of WebAssembly; how it is used, created, and applied?
chikoski
1
650
Functions in JavaScript
chikoski
1
1.1k
20171018-WASM
chikoski
2
1.3k
20171002-wejs
chikoski
1
530
20170924-html5conference-wasm
chikoski
5
10k
Equivalence_in_JS
chikoski
0
1.3k
Design and Implementation of Tech Talks
chikoski
0
110
Other Decks in Technology
See All in Technology
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
260
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
390
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
180
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
アプリエンジニアのためのGraphQL入門.pdf
spycwolf
0
100
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
0
190
Engineer Career Talk
lycorp_recruit_jp
0
190
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Featured
See All Featured
BBQ
matthewcrist
85
9.3k
Raft: Consensus for Rubyists
vanstee
136
6.6k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Agile that works and the tools we love
rasmusluckow
327
21k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Adopting Sorbet at Scale
ufuk
73
9.1k
YesSQL, Process and Tooling at Scale
rocio
169
14k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Typedesign – Prime Four
hannesfritz
40
2.4k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Transcript
いまさら振り返るPromise N.Shimizu (
[email protected]
)
Promise: いずれされる処理を表すオブジェクト https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise 1SPNJTF UIFO GVM'JMMFE UIFO SFKFDUFE DBUDI
SFKFDUFE 1SPNJTF Pending Fulfill Reject Return Return
Promise chain GFUDI IUUQTFYBNQMFDPNFOEQPJOUTPNFBDUJPO UIFO SFTQPOTFSFTQPOTFKTPO FSSOPUJGZ&SSPS FSS
UIFO EBUBEBUBMFOHUI EBUB1SPNJTFSFKFDU OPEBUB UIFO EBUBSFOEFS%BUB EBUB FSSOPUJGZ/P%BUB
処理を始めるところと、結果を利用するところを分けられる EP4PNFUIJOH QBSBN SFTQPOTF\ JG SFTQPOTFFSS \ SFUVSOIBOEMF&SSPS SFTQPOTFFSS
^ EP" EP# EP$ EP% DPOTVNF SFTQPOTFSFTVMU ^ DPOTUQEP4PNFUJOH QBSBN EP" EP# EP$ EP% QUIFO DPOTVNF DBUDI IBOEMF&SSPS
Promise: 条件分岐の一種 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise 1SPNJTF UIFO GVM'JMMFE UIFO SFKFDUFE DBUDI
SFKFDUFE 1SPNJTF Pending Fulfill Reject Return Return
直列化 UFTU" UIFO UFTU# UIFO TVDDFTT DBUDI GBJM
<UFTU" UFTU#> SFEVDF QSP GVOD QSPUIFO GVOD UIFO TVDDFTT DBUDI GBJM 1SPNJTFBMM <UFTU" UFTU# > UIFO TVDDFTT DBUDI GBJM 㛈ᏁҶ⼊ҿӶӔҮ UFTU" UFTU# TVDDFTT GBJM F T T F
並列化 UFTU" DBUDI UFTU# UIFO TVDDFTT DBUDI GBJM
1SPNJTFSBDF <UFTU" UFTU# > UIFO TVDDFTT DBUDI GBJM 㛈ᏁҶ⼊ҿӶӔҮ UFTU" UFTU# TVDDFTT GBJM F T T F
エラー処理を本筋と分けて実装できる MFUSFTVMUEP4PNFUIJOH JG SFTVMUOVMM \ SFTVMUEFGBVMU7BMVF ^ DPOTVNF
SFTVMU EP4PNFUIJOH DBUDI FSSEFGBVMU7BMVF UIFO DPOTVNF
Promise非対応のPromise対応にするには GVODUJPOBEE B C \ SFUVSOB C ^ GVODUJPOQSPNJTFE"EE B
C \ SFUVSO1SPNJTFSFTPMWF B C ^ QSPNJTFE"EE UIFO JDPOTPMFMPH
Promise非対応のPromise対応にするには GVODUJPOBEE B C \ JG B]]C \ UISPXOFX&SSPS *OWBMJEQBSBNFUFS
^ SFUVSOB C ^ GVODUJPOQSPNJTFE"EE B C \ USZ\SFUVSO1SPNJTFSFTPMWF BEE B C ^ DBUDIFSS\SFUVSO1SPNJTFSFKFDU FSS ^ ^
Promise非対応のPromise対応にするには DPOTUGTSFRVJSF GT GVODUJPOSFBE GJMF \ SFUVSOOFX1SPNJTF SFTPMWF SFKFDU
\ GTSFBE'JMF GJMF FSS EBUB \ FSS SFTPMWF FSS SFKFDU EBUB ^ ^ ^
Promise非対応のPromise対応にするには GVODUJPOBEE0OF OVNCFST \ DPOTUSFTVMU<> GPS DPOTUOVNPGOVNCFST \ SFTVMUQVTI OVN
^ ^ GVODUJPOQSPNJTFE"EE0OF OVNCFST \ SFUVSO1SPNJTFBMM OVNCFSTNBQ J1SPNJTFSFTPMWF J ^
Anti-pattern: ネストしたPromise EP" UIFO SFTVMU"\ EP# UIFO SFTVMU#DPOTVNF SFTVMU" SFTTVMU#
^ 1SPNJTFBMM <EP" EP# > UIFO SFTVMUTDPOTVNF SFTVMUT<> SFTVMU<> http://taoofcode.net/promise-anti-patterns/
Anti-pattern: 続かないチェーン GVODUJPOEP4PNFUIJOH \ DPOTUQSPNJTFEP" QSPNJTFUIFO SFTVMUDPOTVNF SFTVMU
SFUVSOQSPNJTF ^ GVODUJPOEP4PNFUIJOH \ SFUVSOEP" UIFO SFTVMUDPOTVNF SFTVMU ^ http://taoofcode.net/promise-anti-patterns/