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

キャッチアップ!The Composable Architecture

キャッチアップ!The Composable Architecture

tatsubee

July 20, 2023
Tweet

More Decks by tatsubee

Other Decks in Technology

Transcript

  1. ͨͭ΂͑
    ΩϟονΞοϓʂ


    The Composable Archtecture

    View full-size slide

  2. ͨͭ΂͑ͬͯ୭ʁ
    ϐΫγϒגࣜձࣾͷ23৽ଔiOSΤϯδχΞ


    ٕज़ελοΫ:


    • ຊۀ: Swift (ྺ1೥)


    • झຯ: Dart/Flutter (ྺ3೥)


    झຯ:


    • ϙέϞϯ


    • ͓ֆඳ͖

    View full-size slide

  3. ࠓ೔࿩͢͜ͱ
    • The Composable Archtectureͬͯͳʹʁ


    • ࣮૷ํ๏


    • جຊతͳ࣮૷


    • Dependencies


    • Test


    • ͓·͚

    View full-size slide

  4. The Composable Archtectureͱ͸ʁ

    View full-size slide

  5. TCAͱ͸ʁ
    The Composable Architecture(TCA)͸υϝΠϯͳͲͰঢ়ଶ؅ཧͷϞδϡʔ
    ϧΛ෼ׂ͠ɺߏ੒Մೳʹ͢Δ͜ͱͰɺେن໛ͰෳࡶͳΞϓϦέʔγϣϯͷ
    ߏஙΛ༰қʹ͢ΔϞμϯͳΞʔΩςΫνϟͰ͢ɻ
    ref: https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428

    View full-size slide

  6. TCAͱ͸ʁ
    ҎԼͷ՝୊Λղܾ͠Α͏ͱ͢ΔϥΠϒϥϦ
    •γϯϓϧͳঢ়ଶ؅ཧ
    •εέʔϥϏϦςΟ
    •෭࡞༻ͷ؅ཧ
    •ςετ༰қੑ
    •։ൃऀʹͱͬͯͷ࢖͍΍͢͞
    ref: https://gist.github.com/kalupas226/bdf577e4a7066377ea0a8aaeebcad428

    View full-size slide

  7. جຊతͳ࣮૷

    View full-size slide

  8. جຊతͳ࣮૷
    • State


    • Action


    • Reducer

    View full-size slide

  9. جຊతͳ࣮૷
    4UBUF
    0
    3FEVDFS
    "DUJPO

    View full-size slide

  10. جຊతͳ࣮૷
    DPVOU
    0
    DPVOU
    UBQ*ODSFNFOU

    View full-size slide

  11. جຊతͳ࣮૷
    4UBUF
    0

    3FEVDFS
    "DUJPO

    View full-size slide

  12. جຊతͳ࣮૷
    4UBUF
    0

    3FEVDFS
    "DUJPO

    View full-size slide

  13. جຊతͳ࣮૷
    4UBUF
    0

    3FEVDFS
    "DUJPO

    View full-size slide

  14. جຊతͳ࣮૷
    4UBUF
    0

    3FEVDFS
    "DUJPO
    &
    ff
    FDU

    View full-size slide

  15. ͪΐͬͱ͍ͬͯ͡ΈΔ

    View full-size slide

  16. جຊతͳ࣮૷
    DPVOU
    0
    DPVOU
    UBQ*ODSFNFOU

    View full-size slide

  17. DPVOU
    جຊతͳ࣮૷

    DPVOU
    0

    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU

    View full-size slide

  18. جຊతͳ࣮૷
    4UBUF
    0

    3FEVDFS
    "DUJPO

    View full-size slide

  19. جຊతͳ࣮૷

    0

    DPVOU
    DPVOU
    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU

    View full-size slide

  20. جຊతͳ࣮૷ + λοϓճ਺

    DPVOU
    0

    0
    UBQQFE
    $PVOU
    DPVOU
    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU

    View full-size slide

  21. جຊతͳ࣮૷ + λοϓճ਺

    0

    0
    UBQQFE
    $PVOU
    UBQQFE$PVOU Ͳ͏௥Ճ͢Δʁ
    DPVOU
    DPVOU
    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU

    View full-size slide

  22. UBQQFE$PVOU
    جຊతͳ࣮૷ + λοϓճ਺
    JODSFBTF
    0
    EFDSFBTF
    0
    UBQQFE
    $PVOU
    Ͳ͏௥Ճ͢Δʁ
    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU

    View full-size slide

  23. جຊతͳ࣮૷ + λοϓճ਺
    JODSFBTF
    0
    EFDSFBTF
    0
    UBQQFE
    $PVOU
    Ͳ͏௥Ճ͢Δʁ
    DPVOU
    UBQ*ODSFNFOU
    UBQ%FDSFNFOU
    UBQQFE$PVOU

    View full-size slide

  24. جຊతͳ࣮૷
    EffectTaskͷ࿩


    • .none


    • .send


    • .run


    (EffectTaskͷ࿩ͷิ଍)

    View full-size slide

  25. جຊతͳ࣮૷
    EffectTaskͷ࿩


    .none


    • ௥ՃͰԿ΋΍Βͳ͍Αʂ

    View full-size slide

  26. جຊతͳ࣮૷
    EffectTaskͷ࿩


    .send


    • ผͷActionΛ௥ՃͰߦ͏Α

    View full-size slide

  27. جຊతͳ࣮૷
    EffectTaskͷ࿩


    .run


    • ඇಉظॲཧΛߦ͏Α


    • ಛ௃


    • sendΛҾ਺ʹ࣋ͭ


    • await͕࢖͑Δ

    View full-size slide

  28. جຊతͳ࣮૷
    EffectTaskͷ࿩ͷิ଍


    ͖ͬ͞ͷίʔυˠ

    View full-size slide

  29. جຊతͳ࣮૷
    EffectTaskͷ࿩ͷิ଍


    ͖ͬ͞ͷίʔυˠ


    ࣮͸Ξϯνύλʔϯ͔΋ʁ

    View full-size slide

  30. جຊతͳ࣮૷
    EffectTaskͷ࿩ͷิ଍


    Ξϯνύλʔϯ


    • 1ͭͷΞΫγϣϯͰ2ͭ෼ͷίετ
    ͕͔͔Δ


    • ࠷ॳͷϩδοΫͷޙʹڧ੍͞ΕΔ


    • ςετංେԽ͢Δ͔΋

    View full-size slide

  31. جຊతͳ࣮૷
    EffectTaskͷ࿩ͷิ଍


    ୯७ʹؔ਺Λ෼཭ͯ͠ղܾͰ͖Δ͔
    ΋

    View full-size slide

  32. جຊతͳ࣮૷
    EffectTaskͷ࿩ͷิ଍


    ద੾ͳ৔߹͸͋Δ

    View full-size slide

  33. Dependencies

    View full-size slide

  34. Dependencies
    ఆٛ


    • ஫ೖ͍ͨ͠class/structΛ࡞੒


    • ຊ൪/ςετͰมߋ͍ͨ͠஋͸஬৯͍
    ঢ়ଶʹ͓ͯ͘͠


    • DependencyKeyΛઃఆ͢Δ


    • live: ຊ൪


    • test: ςετ


    • Preview: XcodeͷϓϨϏϡʔ༻


    • DependencyValueΛઃఆ

    View full-size slide

  35. Dependencies
    ར༻


    • @DependencyͰड͚औΔ

    View full-size slide

  36. Test
    ֤ཁૉ͕ίϯϙʔωϯτԽ͞Ε͍ͯΔ
    ͷͰςετ͕ॻ͖΍͘͢ͳ͍ͬͯΔ

    View full-size slide

  37. Feature
    • 0.55.0


    • Better Bindings Revisited


    • Add Store.send and Store.withState


    • Add Reducer.onChange


    • Add EffectOf


    • TCA1.0ʹ͍ͭͯ

    View full-size slide

  38. TCAͰpixiv clone࡞ͬͯΈͨ

    View full-size slide

  39. pixiv-clone࡞ͬͯΈͨ with TCA
    • https://github.com/Shoryu-Y/swiftui-with-tca


    • ·ͩ·ͩൃల్্


    • جຊతͳ࣮૷ɺDependencyΛऔΓೖΕ͍ͯΔ


    • 0.55.0ͷมߋ΋औΓೖΕͨʁ


    • Test͸·ͩ΍ͬͯͳ͍


    • Navigation͸ࢼߦࡨޡத


    • ࠓޙ΋औΓ૊ΜͰɺࣗ෼ͳΓͷਖ਼ղΛݟ͚͍ͭͨ

    View full-size slide