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
520
いまさら振り返るPromise
chikoski
July 23, 2017
Tweet
Share
More Decks by chikoski
See All by chikoski
20210825_ossx
chikoski
0
280
festudy02-wasm
chikoski
1
950
An overview of WebAssembly; how it is used, created, and applied?
chikoski
1
660
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
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
AIのコンプラは何故しんどい?
shujisado
1
190
なぜCodeceptJSを選んだか
goataka
0
160
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
100
Postman と API セキュリティ / Postman and API Security
yokawasa
0
200
Amazon VPC Lattice 最新アップデート紹介 - PrivateLink も似たようなアップデートあったけど違いとは
bigmuramura
0
190
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
250
UI State設計とテスト方針
rmakiyama
2
450
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
170
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
150
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Mobile First: as difficult as doing things right
swwweet
222
9k
Why Our Code Smells
bkeepers
PRO
335
57k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Six Lessons from altMBA
skipperchong
27
3.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Facilitating Awesome Meetings
lara
50
6.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Designing for Performance
lara
604
68k
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/