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
信頼性に挑む中で拡張できる・得られる1人のスキルセットとは?
ken5scal
2
530
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
300
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
7
760
Platform Engineering for Software Developers and Architects
syntasso
1
510
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
Amazon Personalizeのレコメンドシステム構築、実際何するの?〜大体10分で具体的なイメージをつかむ〜
kniino
1
100
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
110
Engineer Career Talk
lycorp_recruit_jp
0
140
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
4 Signs Your Business is Dying
shpigford
180
21k
What's in a price? How to price your products and services
michaelherold
243
12k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Navigating Team Friction
lara
183
14k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Designing Experiences People Love
moore
138
23k
Agile that works and the tools we love
rasmusluckow
327
21k
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/