Upgrade to Pro — share decks privately, control downloads, hide ads and more …

いまさら振り返るPromise

 いまさら振り返るPromise

chikoski

July 23, 2017
Tweet

More Decks by chikoski

Other Decks in Technology

Transcript

  1. Promise chain GFUDI IUUQTFYBNQMFDPNFOEQPJOUTPNFBDUJPO  UIFO SFTQPOTFSFTQPOTFKTPO FSSOPUJGZ&SSPS FSS 

    UIFO EBUBEBUBMFOHUI EBUB1SPNJTFSFKFDU OPEBUB  UIFO EBUBSFOEFS%BUB EBUB FSSOPUJGZ/P%BUB 
  2. 処理を始めるところと、結果を利用するところを分けられる 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
  3. 直列化 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
  4. 並列化 UFTU" DBUDI UFTU#  UIFO TVDDFTT DBUDI GBJM 

    1SPNJTFSBDF <UFTU" UFTU# > UIFO TVDDFTT DBUDI GBJM  㛈ᏁҶ੢⼊ҿӶӔҮ UFTU" UFTU# TVDDFTT GBJM F T T F
  5. Promise非対応のPromise対応にするには GVODUJPOBEE B C \ SFUVSOB C ^ GVODUJPOQSPNJTFE"EE B

    C \ SFUVSO1SPNJTFSFTPMWF B C  ^ QSPNJTFE"EE   UIFO JDPOTPMFMPH   
  6. 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 ^ ^
  7. Promise非対応のPromise対応にするには DPOTUGTSFRVJSF GT  GVODUJPOSFBE GJMF \ SFUVSOOFX1SPNJTF SFTPMWF SFKFDU

    \ GTSFBE'JMF GJMF  FSS EBUB \ FSS SFTPMWF FSS SFKFDU EBUB  ^ ^ ^ 
  8. Promise非対応のPromise対応にするには GVODUJPOBEE0OF OVNCFST \ DPOTUSFTVMU<> GPS DPOTUOVNPGOVNCFST \ SFTVMUQVTI OVN

      ^ ^ GVODUJPOQSPNJTFE"EE0OF OVNCFST \ SFUVSO1SPNJTFBMM OVNCFSTNBQ J1SPNJTFSFTPMWF J   ^
  9. 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/
  10. Anti-pattern: 続かないチェーン GVODUJPOEP4PNFUIJOH \ DPOTUQSPNJTFEP"  QSPNJTFUIFO SFTVMUDPOTVNF SFTVMU 

    SFUVSOQSPNJTF ^ GVODUJPOEP4PNFUIJOH \ SFUVSOEP" UIFO SFTVMUDPOTVNF SFTVMU  ^ http://taoofcode.net/promise-anti-patterns/