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
APIとはなにか
mikanichinose
0
100
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
320
ずっと昔に Star をつけたはずの思い出せない GitHub リポジトリを見つけたい!
rokuosan
0
150
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
270
.NET 9 のパフォーマンス改善
nenonaninu
0
1k
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
5分でわかるDuckDB
chanyou0311
10
3.2k
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
570
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.4k
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
It's Worth the Effort
3n
183
28k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
We Have a Design System, Now What?
morganepeng
51
7.3k
Six Lessons from altMBA
skipperchong
27
3.5k
Navigating Team Friction
lara
183
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
GraphQLとの向き合い方2022年版
quramy
44
13k
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/