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

Why use Redux in iOS

Why use Redux in iOS

yohei sugigami

March 22, 2018
Tweet

More Decks by yohei sugigami

Other Decks in Technology

Transcript

  1. ɹ
    ɹ
    Why use Redux in iOS
    ɹ
    ɹ
    ɹ
    iOS Flux/Reduxษڧձ
    2018/03/22@Wantedly
    Yohei Suginami ( @susieyy )

    View full-size slide

  2. Profile
    — Yohei Sugigami
    — susieyy
    — Twitter / Qiita / Github
    — New app development
    specialist
    — Clients
    — Folio.inc
    — New app developer
    — Wantedly.inc
    — Technical advisor

    View full-size slide

  3. ɹ
    ɹ
    ɹ
    ɹ
    Flux/Redux੝Γ্͕ͬͯ·͢Ͷʂ

    View full-size slide

  4. ɹ
    ɹ
    ɹ
    ɹ
    ϨΩγΛৼΓฦΔ

    View full-size slide

  5. ɹ
    ɹ
    ɹ
    ɹ
    ೔ຊͰ΋࠾༻ࣄྫ͕૿͑ͯ·͢Ͷʂ

    View full-size slide

  6. ɹ
    ɹ
    ͳͥReduxͳͷ͔

    View full-size slide

  7. ɹ
    ɹ
    ΞϓϦ։ൃʹ͓͚Δ
    ࠷େͷ՝୊͸ɹɹɹ

    View full-size slide

  8. ɹ
    ɹ
    ෳࡶͰ͋Δ͜ͱ

    View full-size slide

  9. Ͳ͏γϯϓϧʹམͱ͠ࠐΉ͔ɹɹɹ
    ɹ
    ɹ
    ɹ
    ɹ
    ೺Ѳɾ؅ཧͰ͖ΔΑ͏ʹ͢Δ͔

    View full-size slide

  10. ΞϓϦ։ൃʹ͓͚Δෳࡶੑͱ͸
    खଓ͖తهड़ʹΑΔॲཧͷྲྀΕͷ೺Ѳͷ͠ʹ͘͞
    — σϦήʔτύλʔϯͷίʔϧόοΫ஍ࠈ
    — ϑΝοτίϯτϩʔϥʔ໰୊

    View full-size slide

  11. ΞϓϦ։ൃʹ͓͚Δෳࡶੑͱ͸
    Өڹൣғͷෆ͔֬͞΍ɺہॴԽ͞Εͣ޿ҬͳӨڹൣғ
    — γϯάϧτϯʢάϩʔόϧม਺ͷଟ༻ʣ

    View full-size slide

  12. ΞϓϦ։ൃʹ͓͚Δෳࡶੑͱ͸
    ଟ༷ͳঢ়ଶͷදݱͷͨΊʹଟ਺ͷ෼ذͱଟ਺ͷม਺ͷग़ݱ
    — ม਺͕มԽ͢ΔཁҼ͕఺ࡏԽ
    — ৚݅෼ذʹ͸࢓্༷ભҠ͠ͳ͍ܦ࿏΋ؚ·ΕΔ

    View full-size slide

  13. ॾѱͷࠜݯ͸MVC
    ෳࡶੑͷղܾࡦΛMVCʹมΘΔΞʔΩςΫνϟ΁ٻΊͨ
    — MVVMʢCʣʴFRP
    — CleanAcrhitecture / Viper
    — Flux / Redux

    View full-size slide

  14. MVVMʢCʣʴFRP
    ෳࡶੑ΁ͷରቂ
    — ϦΞΫςΟϒͳؔ਺ʹந৅Խ͠ɺ୺తͰએݴతͳهड़
    — ࿈ଓ͢Δ૬ޓ࡞༻Λѻ͍΍͍͢
    — ঢ়ଶอ࣋ͷͨΊͷม਺Λ࡟ݮ
    — ↑ RxͷετϦʔϜʹ಺แ
    — ඇಉظΛབྷΊͨॲཧͷՄಡੑߴ͍දݱྗ
    — εϐʔυײ͋Δ։ൃ

    View full-size slide

  15. MVVMʢCʣʴFRP
    σϝϦοτ
    — ߴ͍ͷந৅ԽʹΑΔهड़೉қ౓ͷ্ঢ
    — ෳࡶͳRxͷΦϖϨʔλʔΛۦ࢖͢Δ͜ͱͰ͔͑ͬͯڍಈ͕
    Θ͔Γʹ͍͘
    — ϚϧνεϨουͳॲཧ͸֤ετϦʔϜͰಠཱతʹಈ࡞͢Δ
    — هड़ྗ͸ߴ͍͕ಈ࡞ͷ೺Ѳɾσόοά͸͠ʹ͍͘

    View full-size slide

  16. CleanAcrhitecture / Viper
    ෳࡶੑ΁ͷରቂ
    — ΦϒδΣΫτࢦ޲ͷ੹຿෼ׂͰγϯϓϧʹམͱ͠ࠐΉ
    — ϨΠϠʔ෼ׂɾґଘͷࢦ޲ੑ
    — ϨΠϠʔͷΠϯλʔϑΣΠεͱ࣮૷ͷ෼཭ʹΑΔந৅Խ
    — νʔϜεέʔϥϏϦςΟͷ޲্

    View full-size slide

  17. CleanAcrhitecture / Viper
    σϝϦοτ
    — ৑௕ʹΑΔهड़ྔ͕૿͑Δίʔυ
    — ։ൃεϐʔυͷݮ଎
    — ঢ়ଶͱखଓ͖ΛΧϓηϧԽʹΑΔγϯϓϧԽͷݶք

    View full-size slide

  18. ɹ
    ɹ
    Reduxͱ͸Կ͔

    View full-size slide

  19. Մಡੑͷ޲্
    ॻ͘ίετΑΓ΋ɺಡΉίετΛԼ͛Δ
    — ಡΈ΍͘͢ɺ΍Γ͍ͨ͜ͱɾॲཧ͕೺Ѳ͠΍͍͢
    — Өڹൣғ͕ਪఆ͠΍͍͢
    — ϨϏϡʔ͠΍͍͢
    — εϐʔυײ͋Δ։ൃ
    — ΞϓϦن໛ͱνʔϜߏ੒ͷεέʔϥϏϦςΟͷ޲্

    View full-size slide

  20. Viewͱঢ়ଶͷ׬શͳΔ෼཭
    — ViewͷॲཧͰ͸ͦͷॠؒͷΞϓϦ಺ͷ͢΂ͯͷঢ়ଶ
    ʢState)͕ҰҙͰ͋Δ͜ͱΛอূ͞ΕΔ
    — State͸Πϛϡʔλϒϧ
    — ͦͷॠؒͷঢ়ଶʹରͯ͠ඇಉظͷհೖ͕ͳ͍
    — ViewʹState౉Δͱදࣔ͸Ұҙʹܾ·Δ
    — View͕ؔ਺ܕࢦ޲ʹͳΔ

    View full-size slide

  21. ७ਮؔ਺
    — ೖྗʹରͯ݁͠Ռ͕ҰҙͰ͋Δ
    — ϓϩάϥϛϯάʹ͓͍ͯϩδοΫΛγϯϓϧѻ͏ͨΊͷۃ
    Έ
    — ෭࡞༻ഉআͱ෼཭
    — ςελϏϦςΟ޲্

    View full-size slide

  22. Ϛγϯύϫʔ্͕͕ͬͨ͜ͱʹΑΔ෋߽తͳΞʔΩςΫνϟ
    ϚγϯύϫʔΛ͏·͘ར༻͢Δ͜ͱͰγϯϓϧΛ࣮ݱ͍ͯ͠Δ
    ॲཧͷ௚ྻԽ
    - ϝΠϯεϨου্ͰϏδωεϩδοΫ(ߋ৽ॲཧ)ͷಈ࡞
    - γϯάϧϝΠϯεϨου͚ͩͰಈ࡞͍ͯ͠ΔΑ͏ͳײ֮ͰΞ
    ϓϦ͕ॻ͚Δ
    Viewͷޮ཰తͳߋ৽ͷͨΊͷࠩ෼ݕ஌ίετ
    - ϏδωεϩδοΫ͸ॲཧޙͷViewͷӨڹൣғΛؔ஌͠ͳ͍

    View full-size slide

  23. Swi!ݴޠͱͷ૬ੑͷྑ͞
    — TypeSafe
    — Struct / Immutable
    — ComputedProperty
    — Enum / PatternMatch
    — Generics
    — Functional Oriented
    — Protocol Oriented

    View full-size slide

  24. σόοά༰қੑ
    ɹ
    DEMO

    View full-size slide

  25. Redux՝୊఺
    — ΞΫγϣϯͷॱংੑΛ੍໿͚͍ͮͨʢεςʔτϚγϯʣ
    — Actionϧʔϓ໰୊
    — StateͷΠχγϟϥΠζͱΦϓγϣϯφϧ
    — ϝϞϦϚωδϝϯτʢը໘ഁغ࣌ʹ෦෼Stateͷഁغʣ
    — Viewͷޮ཰తͳߋ৽ͷͨΊͷࠩ෼ߋ৽ʢվળͷ༨஍͋Γʣ

    View full-size slide

  26. Redux͸ۜͷ஄ؙͰ͸ͳ͍
    ɹ
    ɹ
    ɹ
    దࡐ͔Ͳ͏͔͸ɹɹɹɹɹ
    ΞϓϦཁ݅ɺ඼࣭ཁ݅ɹɹɹɹ
    νʔϜߏ੒ɺ։ൃظؒ࣍ୈɹɹ

    View full-size slide

  27. ·ͱΊ
    Redux͸ඇৗʹݫ֨ɾݎ࿚Ͱ͋ΓγϯϓϧͳϩδοΫܗ੒
    — ७ਮؔ਺
    — Πϛϡʔλϒϧ
    — ୯Ұࢦ޲ੑϑϩʔ ʢ ϚϧνεϨουͷہॴԽ ʣ
    — ෭࡞༻ʢඇಉظॲཧʣͷہॴԽ

    View full-size slide

  28. ߹ΘͤͯಡΈ͍࣮ͨફฤ
    ɹ
    Redux+RxΛ׆༻ͨ͠ΞϓϦΞʔ
    ΩςΫνϟ
    CA.swi! #5
    2018/01/25@גࣜձࣾαΠόʔΤʔδΣϯτ
    Yohei Suginami ( @susieyy )

    View full-size slide