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

Rx分からんを解消する会

 Rx分からんを解消する会

社内勉強会での資料です。
RxSwiftについて開発メンバーから寄せられた質問に対して答える感じで用意した資料となります。

47addc68d5b643d7ee875059b42404eb?s=128

Suguru Kishimoto

October 22, 2018
Tweet

Transcript

  1. Komerco Div 2018.10.22(MON) Rx෼͔ΒΜΛղফ͢Δձ 3Y෼͔ΒΜΛղফ͢Δձ 4VHVSV,JTIJNPUP

  2. Cookpad Inc. All Rights Reserved. ࣄͷൃ୺

  3. Cookpad Inc. All Rights Reserved.

  4. Cookpad Inc. All Rights Reserved.

  5. Cookpad Inc. All Rights Reserved. ͻͬͦΓ΍Δͭ΋Γ͕ѹ͕͔͔ͬͨͷͰ ษڧձܗࣜͰ΍Δ͜ͱʹ

  6. Cookpad Inc. All Rights Reserved. ⚠ॾ஫ҙ⚠ wدͤΒΕ࣭ͨ໰Λݩʹࢿྉ࡞ͬͯ·͢ wޙ൒͸ࣗ༝࣌ؒʹ͢ΔͷͰΘ͍Θ͍ٞ࿦ͨ͠Γ͠·͠ΐ͏

  7. Cookpad Inc. All Rights Reserved. ૣ଎

  8. ʲQ1ʳ Observable,Observer,Subject,Relay,Signal,Driver… ͦΕͧΕͷ໾ׂͱ͔࢖͍ಓ͸?

  9. Cookpad Inc. All Rights Reserved. 0CTFSWBCMF0CTFSWFS w0CTFSWBCMFσʔλιʔεɺετϦʔϜͱ͔ݺ͹ΕΔɻ஋͕ྲྀΕͯ ΔɺA؍ଌͰ͖Δ΋ͷAɻ
 ஋͕ྲྀΕͯ͘Δͱɺࣗ৴ʹొ࿥͞Εͨ0CTFSWFSʹ஋Λ௨஌͢Δ
 w0CTFSWFSA؍ଌ͢Δ΋ͷAɻ0CTFSWBCMFͰྲྀΕ͍ͯΔ஋Λड͚औ

    ΔͨΊʹɺ0CTFSWBCMFʹࣗ਎Λొ࿥ͨ͠ΓɺෆཁʹͳͬͨΒղআ ͨ͠Γ͢Δ
  10. Cookpad In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VCKFDUɺ#FIBWJPS3FMBZ͸#FIBWJPS4VCKFDU

    ͷϥούʔʹͳ͍ͬͯΔ w&SSPS $PNQMFUFE͕ྲྀΕͳ͍ͷͰɺ
 1VCMJTI3FMBZˠ4JHOBM
 #FIBWJPS3FMBZˠ%SJWFS
 ʹ؆୯ʹม׵Ͱ͖Δ
  17. Cookpad Inc. All Rights Reserved. 4JOHMF.BZCF$PNQMFUBCMF w3Y4XJGUW͔Β౥ࡌ͞Εͨɺ0CTFSWBCMF&ͷᙱ͍ͱ͜ΖΛγʔϯ ผʹղܾͯ͘͠ΕΔ΋ͷɻͦΕͧΕFWFOU͸ճ͔͠ྲྀΕͳ͍ wඞͣ&SSPS͔$PNQMFUFEͷͲͪΒ͔ͰऴΘΔ w/FYUͷྲྀΕΔճ਺͕ҧ͏

    w4JOHMFճ w.BZCFճ΋͘͠͸ճ ྲྀΕͣʹ$PNQMFUFE͚ͩྲྀΕΔ͜ͱ͕͋Δ  w$PNQMFUBCMFճ
  18. Cookpad Inc. All Rights Reserved. %SJWFS4JHOBM w&SSPS͕ྲྀΕͳ͍ wϝΠϯεϨουͰ࣮ߦ͞ΕΔ͜ͱ͕อূ͞Ε͍ͯΔ w%SJWFS͸4VCTDSJCFͨ࣌͠ʹ௚ۙͷ஋Λճྲྀ͢ ASFQMBZ

     A  w4JHOBM͸4VCTDSJCF͔ͯ͠ΒྲྀΕͯ͘Δ w6*ʹབྷΉ෦෼Ͱ࢖͏ͷʹ΋͍ͬͯ͜ w1SFTFOUFSˠ7JFXɺ7JFX.PEFMˠ7JFXͰΑ͘࢖͏
  19. Cookpad Inc. All Rights Reserved. ࢀߟ w3Y$PDPBͷ4JHOBMͱ3FMBZͷ·ͱΊ wIUUQTUFDINFSDBSJDPNFOUSZ w3Y4XJGUͷ༻ޠ·ͱΊ wIUUQTRJJUBDPNNPSJTIJOJUFNTDEFCGF

    w3Y4XJGUͷ0CTFSWBCMFͱ͸Կ͔ wIUUQTRJJUBDPNHPNJ@OJOHFOJUFNTDDGFCFFDG w3Y4XJGUΛ΍ΔલʹͪΌΜͱ0CTFSWFSύλʔϯΛֶͿ wIUUQTTUBSIPTIJIBUFOBCMPHDPNFOUSZ 394XJGU@&&&#&%&"#&"&& &"@0CTFSWFS@&&#'&#$&#&&"%" &#
  20. ʲQ2ʳ `subscribe`, `bind`, `drive`, `emit` ͷ࢖͍෼͚͸?

  21. Cookpad Inc. All Rights Reserved. ͲΕ΋ߪಡ͢Δ࣌ʹ࢖͏΋ͷ͚ͩͲ ඍົʹੑ࣭͕ҟͳΔ

  22. Cookpad Inc. All Rights Reserved. ATVCTDSJCF PO/FYUʜ A wOFYU FSSPS

    DPNQMFUFE TVCTDSJCFE EJTQPTFEɺͦΕͧΕड͚औͬ ͨͱ͖ͷॲཧΛهड़Ͱ͖Δ w4JOHMF .BZCF $PNQMFUBCMFʹͳΔͱड͚औΕΔ΋ͷ͕มΘΔ
  23. Cookpad Inc. All Rights Reserved. ACJOE UP A wྲྀΕΛଞͷετϦʔϜʹͭͳ͛Δ࣌ʹ࢖͏ wҾ਺ʹ͸0CTFSWFS5ZQF΋͘͠͸3FMBZ͕ೖΔ


    ͕ɺϨγʔόͷ0CTFSWBCMF5ZQFʹΑͬͯएׯมΘΔ
  24. Cookpad Inc. All Rights Reserved. ACJOE PO/FYU A wOFYUΛड͚औͬͨͱ͖ͷॲཧΛهड़Ͱ͖Δ
 ATVCTDSJCF

    PO/FYU AͷΈͷ7FSͩͱࢥ͑͹ྑ͍ wFSSPS͕ྲྀΕͯ͜ͳ͍લఏʹͳ͍ͬͯΔͷͰɺ %FCVH؀ڥͰ͸ ྲྀΕ ͯ͘ΔͱΫϥογϡ͢Δ w3FMBZΛTVCTDSJCF͢Δͱ͖͸ͬͪ͜Ͱॻ͘΄͏͕ؾ࣋ͪ୹͍ͷͰ γϯϓϧʹॻ͚Δ
  25. Cookpad Inc. All Rights Reserved. AESJWF @ A AFNJU UP

    A wACJOE UP Aͷ%SJWFS4JHOBM൛ wESJWF͸0CTFSWFS5ZQFɺ#FIBWJPS3FMBZͱ wFNJU͸0CTFSWFS5ZQFɺ1VCMJTI3FMBZͱ
  26. Cookpad Inc. All Rights Reserved. ESJWF FNJU AYY PO/FYU A

    wESJWF͸%SJWFSʹରͯ͠ɺFNJU͸4JHOBMʹରͯ͠࢖͏ wOFYU DPNQMFUFE EJTQPTFEΛड͚औΕΔ
  27. ʲQ3ʳ ΞϓϦͰΑ͘ݟΔ࣮૷ύλʔϯΈ͍ͨͷ͕ ͋Ε͹஌Γ͍ͨͰ͢ɻ - MVVMͰUIͱVMΛόΠϯυ͢Δͱ͖ͱ͔ɻ - WebAPIୟ͍ͯUI·Ͱ൓өͤ͞Δ·ͰͷྲྀΕͱ͔ɻ

  28. Cookpad Inc. All Rights Reserved. ύλʔϯΛֶͿͷʹ͓͢͢Ί͸ͪ͜Β

  29. Cookpad Inc. All Rights Reserved. w3Y4XJGUͷ&YBNQMF wIUUQTHJUIVCDPN3FBDUJWF93Y4XJGUCMPCNBTUFS%PDVNFOUBUJPO &YBNQMFTNE w3Y1BHJOBUJPO wIUUQTHJUIVCDPNUSZTXJGU3Y1BHJOBUJPO

    w3Y4XJGU "1*SFRVFTU .77. wIUUQTTQFBLFSEFDLDPNTMJHIUBJSSYTXJGUQMVTBQJSFRVFTUQMVTNWWN
  30. Cookpad Inc. All Rights Reserved. .77.ͷྫΛऔΔͱʜ w7.ͷJOJUͰWJFXͷΠϕϯτΛ0CTFSWBCMFͱͯ͠౉͢͜ͱ͕ଟ͍
 FHϘλϯͷλοϓɺϦϩʔυͷτϦΨʔʜ  w"1*ୟ͘ͱ͜Ζ΋3YͰϥοϓͯ͠ετϦʔϜΛ࡞Δ

    w7JFXͷΠϕϯτΛجʹɺ"1*ͷετϦʔϜΛܨ͍Ͱ͋͛ͯɺ݁Ռ΍ ΤϥʔΛ%SJWFS΍4JHOBMΛ࢖ͬͯ౉ͯ͋͛͠Δ w7JFXଆͰ஋Λ͙͢ʹࢀর͍ͨ͠ͱ͖͸7.ʹ#FIBWJPS3FMBZΛ༻ҙ ͯ͠ɺASFMBZWBMVFAͰࢀর͢Δ
  31. ʲQ4ʳ ΩϨΠʹετϦʔϜΛ࡞Δʹ͸?

  32. Cookpad Inc. All Rights Reserved. ΩϨΠͳετϦʔϜΛ૊Ήʹ͸ɺ ετϦʔϜʹखΛՃ͑ΔΦϖϨʔλʔΛ ཧղ͢Δඞཁ͕͋Δ

  33. Cookpad Inc. All Rights Reserved. KVTU FSSPS FNQUZ OFWFS DSFBUF

    PG EFGFS  GJMUFS NBQ [JQ DPNCJOF-BUFTU  XJUI-BUFTU'SPN DPODBU NFSHF GMBU.BQ  GMBU.BQ-BUFTU GMBU.BQ'JSTU UBLF TLJQ SFUSZ  BNC DBUDI TXJUDI UISPUUMF EFCPVODF  UJNFPVU CVGGFS XJOEPXʜ ˞ݴޠʹΑͬͯඍົʹΦϖϨʔλʔ໊͕ҟͳͬͨΓ͢Δ৔߹͋Γ
  34. Cookpad Inc. All Rights Reserved. Ұ౓ʹ֮͑Δͷ͸େม গͣͭ͠ಈ࡞Λཧղ͠ͳ͕ΒਂΊ͍ͯ͘

  35. Cookpad Inc. All Rights Reserved. ʮͲ͔͜ʹ·ͱ·ͬͯͳ͍ͷʁʯ

  36. Cookpad Inc. All Rights Reserved. 0QFSBUPSΛֶͿ w3FBDUJWF90QFSBUPST wIUUQSFBDUJWFYJPEPDVNFOUBUJPOPQFSBUPSTIUNM w3Y.BSCMFT 3Y+4

     wIUUQSYNBSCMFTDPN w3Y.BSCMFTͷJ04"QQ΋͋Δ
  37. Cookpad Inc. All Rights Reserved.

  38. Cookpad Inc. All Rights Reserved. ʮཧղ͢Δͱදݱͷ෯͕޿͕Δͷ͸ʁʯ

  39. Cookpad Inc. All Rights Reserved. KVTU FSSPS FNQUZ OFWFS DSFBUF

    PG EFGFS  GJMUFS NBQ [JQ DPNCJOF-BUFTU  XJUI-BUFTU'SPN DPODBU NFSHF GMBU.BQ  GMBU.BQ-BUFTU GMBU.BQ'JSTU UBLF TLJQ SFUSZ  BNC DBUDI TXJUDI UISPUUMF EFCPVODF  UJNFPVU CVGGFS XJOEPXʜ
  40. ࠓ͙͢࢖͑ΔςΫχοΫ

  41. Cookpad Inc. All Rights Reserved. ͦͷ̍ AXJUI-BUFTU'SPNA

  42. Cookpad Inc. All Rights Reserved.

  43. Cookpad Inc. All Rights Reserved. TVCTDSJCFͷதͰTFMGࢀরͯ͠ ଞͷετϦʔϜͷ஋Λͭͳ͛Δͷ͸ආ͚͍ͨ

  44. Cookpad Inc. All Rights Reserved.

  45. Cookpad Inc. All Rights Reserved. ετϦʔϜͱɺࢦఆͨ͠ετϦʔϜͷ௚ۙͷ஋Λ ͏·ͭ͘ͳ͛Δ͜ͱ͕Ͱ͖Δ

  46. Cookpad Inc. All Rights Reserved. ͦͷ A[JQA

  47. Cookpad Inc. All Rights Reserved.

  48. Cookpad Inc. All Rights Reserved. ࠩ෼ΛऔΔͷ͕؆୯ʹͳΔ

  49. Cookpad Inc. All Rights Reserved. ͦͷ ATDBOA ATUBSU8JUIA

  50. Cookpad Inc. All Rights Reserved.

  51. Cookpad Inc. All Rights Reserved.

  52. Cookpad Inc. All Rights Reserved. "1*ͰQBHFࢦఆͯ͠ಡΈࠐΜͰ݁ՌΛ ஷΊ͍ͯ͘ͷʹศར

  53. Cookpad Inc. All Rights Reserved. ͦͷ "DUJPO IUUQTHJUIVCDPN3Y4XJGU$PNNVOJUZ"DUJPO

  54. Cookpad Inc. All Rights Reserved. "DUJPO w3Y4XJGU$PNNVOJUZͰఏڙ͞Ε͍ͯΔ044 w*OQVUͱ0VUQVU͕ܾ·ͬͨετϦʔϜͷྲྀΕΛΞΫγϣϯͱͯ͠ఆ ٛ͢Δ wͦͷΞΫγϣϯͷ݁Ռ

    FMFNFOU ɺΤϥʔ FSSPS ɺ࣮ߦத͔Ͳ͏͔ FYDVUJOH ͕ͦΕͧΕετϦʔϜͱͯ͠ఏڙ͞ΕΔ w"1*ͷ௨৴΍Կ͔͠ΒͷඇಉظॲཧΛଋͶΔͷʹศར wADBUDI&SSPSA AEPAͱA<XFBLTFMG>Aͷۤ͠Έ͔Βղ์ͯ͘͠ΕΔ
  55. Cookpad Inc. All Rights Reserved.

  56. Cookpad Inc. All Rights Reserved. "DUJPOΛ࢖͏ͱ͜͏ͳΔ

  57. Cookpad Inc. All Rights Reserved.

  58. Cookpad Inc. All Rights Reserved. ͦͷଞ ࿩͔ͨͬͨ͜͠ͱ w)PU$PME0CTFSWBCMF wTIBSF SFQMBZ

     w4DIFEVMFS w#JOEFS
  59. Cookpad Inc. All Rights Reserved. ͕ͬͭΓಡΈͳ͕ΒֶͿͳΒ w3Y4XJGU3FBDUJWF1SPHSBNNJOHXJUI4XJGU wIUUQTTUPSFSBZXFOEFSMJDIDPNQSPEVDUTSYTXJGUSFBDUJWF QSPHSBNNJOHXJUITXJGU

  60. None