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
ネイティブアプリでもFluxしたい
Search
Kenichi Yonekawa
April 08, 2016
Programming
0
2.1k
ネイティブアプリでもFluxしたい
http://connpass.com/event/28794/
Kenichi Yonekawa
April 08, 2016
Tweet
Share
More Decks by Kenichi Yonekawa
See All by Kenichi Yonekawa
iOSアプリの設計とDependency Injection
yonekawa
22
16k
Fluxで複雑な状態の変化を予測可能にするiOSアプリ開発
yonekawa
9
19k
freeeモバイルチームの変遷と進化
yonekawa
0
7.4k
ReactiveCocoa Pitfalls at freee
yonekawa
2
830
RAC用クラス拡張の作り方
yonekawa
2
2.9k
Dive into Joybox
yonekawa
5
1.7k
Other Decks in Programming
See All in Programming
初めてDefinitelyTypedにPRを出した話
syumai
0
410
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
EventSourcingの理想と現実
wenas
6
2.3k
cmp.Or に感動した
otakakot
2
150
as(型アサーション)を書く前にできること
marokanatani
10
2.6k
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
24k
Quine, Polyglot, 良いコード
qnighy
4
640
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
What's new in Ruby 2.0
geeforr
343
31k
Adopting Sorbet at Scale
ufuk
73
9.1k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Site-Speed That Sticks
csswizardry
0
23
Navigating Team Friction
lara
183
14k
Fireside Chat
paigeccino
34
3k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Typedesign – Prime Four
hannesfritz
40
2.4k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
A Tale of Four Properties
chriscoyier
156
23k
Transcript
@yonekawa ωΠςΟϒΞϓϦͰ 'MVY͍ͨ͠
ʔ͍ϑϩϯτΤϯυͷ ษڧձͰ4XJGUͷ͢ΔΑʔ
ࡢࠓͷiOSΞϓϦ • RxSwiftʢϦΞΫςΟϒϓϩάϥϛϯάʣ͕ྲྀߦͷஹ͠ • MVVMΞʔΩςΫνϟ͕ຊ֨తʹྲྀߦ͖ͬͯͯΔ • ViewModelͰAPIୟ͍ͯViewʹྲྀ͠ࠐΉ • RxSwiftUIόΠϯσΟϯά༻ͷΈ͕ॆ࣮
freeeͷiOSΞϓϦ • MVVMΛॳظ͔Βಋೖ͠ɺViewModelʹΑͬͯViewͷঢ়ଶ ͱϏδωεϩδοΫΛཧ͍ͯ͠Δ • ϦΞΫςΟϒϓϩάϥϛϯάʹReactiveCocoaΛ͍ͬͯ Δ • ෳࡶͳೖྗϑΥʔϜɺػೳͷଟ͞ͱͦΕΒͷؔ࿈ͷଟ͞
՝ײ • ن͕େ͖͘ͳΔʹͭΕͯUIΠϕϯτɺγεςϜΠϕϯτʹ ΑΔڍಈΛίϯτϩʔϧͰ͖ͳ͘ͳ͖ͬͯͨ • ViewModelͱͷํόΠϯσΟϯάͱͦΕΒͷґଘؔ ͷ༧ଌͷͮ͠Β͞ • ঢ়ଶͷཧͱϞσϧͷૢ࡞ͱAPIૢ࡞͕ີ݁߹
Ͳ͜ͰԿ͕ى͖ͯΔ͔Α͘ Θ͔ΒΜ
୭͔ॿ͚ͯ͘Ε
None
͓ͬʁ
Ǒ2way-bindingͰɺViewModelͰViewͷ Modelͷཧ͠ͳ͍ͱ͍͚ͳ͍ͱ ͜Ζ͕ͭΒ͞ͷݪҼʹͳ͍ͬͯΔɻ ǒ
Θ͔Δɻ
Ǒ͡Ό͋ͦͦViewΛඳը͢Δͱ͖ʹɺ Modelͷঢ়ଶ͔Βશ෦࠶ඳը͢Ε͍͍Μ ͡Όͳ͍ʁ ͦͨ͠ΒModelͷΛཧ͢Δ͚ͩͰྑ͘ ͳͬͯɺViewͷߟ͑ͳͯ͘Α͘ͳΔΜ ͡Όͳ͍ʁ ǒ
Ǒ͜ΕʹϐλϦͱ·Δͷ͕Fluxͱ͍͏֓೦ Ͱɺ͜ΕViewͷதͰͷͷมߋΛͦͷ· ·ViewͰॲཧΛͤͣɺผͷʹྲྀ͠ࠐΈ ·͢ɻ ǒ
ͳΔ΄Ͳʁ
SwiftFlux͍ͬͯ͏ϥΠϒϥϦΛ࡞ͬͨΑ • https://github.com/yonekawa/SwiftFlux • DispatcherͱͦΕʹඥͮ͘Action/StoreͷநԽ • ReduceStoreͱ͔Flux UtilsҰ෦࣮ͯ͠Δ • ϓϩτίϧࢦͰSwiftΒ͠͞Λҙࣝ
࣮ઓೖͯ͠ΔΑ https://itunes.apple.com/jp/app/id1037197002
୯ํϑϩʔ with ܕ੍ TUSVDU$SFBUF5PEP"DUJPO\ UZQFBMJBT1BZMPBE5PEP GVODJOWPLF EJTQBUDIFS%JTQBUDIFS \ MFUUPEP5PEP UJUMF/FX5P%P
EJTQBUDIFSEJTQBUDI TFMG SFTVMU3FTVMU WBMVFUPEP ^ ^ DMBTT5PEP4UPSF4UPSF#BTF\ QSJWBUF TFU WBSUPEP5PEP JOJU \ SFHJTUFS $SFBUF5PEPTFMG \ SFTVMU JO TXJUDISFTVMU\ DBTF4VDDFTT MFUWBMVF UPEPWBMVF FNJU$IBOHF EFGBVMU CSFBL ^ ^ ^ ^
ΞϓϦͷ։ൃํ • جຊతʹViewControllerͱ1:1ͰStoreΛ࡞Γঢ়ଶΛཧ͢Δ • ͦΕͱผͰΞϓϦέʔγϣϯશମͷঢ়ଶʢೝূ͍ͯ͠Δͱ͔ʣ Λཧ͢ΔStoreΛ࡞Δ • APIϦΫΤετActionͰߦ͍݁ՌΛActionͷPayloadͱͯ͠ ѻ͏ •
Realm(DB)ͷอଘΞϓϦέʔγϣϯͷঢ়ଶมԽͱΈͳ͠ StoreͰߦ͏
Viewͷߋ৽Ͳ͏͢Δʁ • SwiftͷੈքʹReact͕ଘࡏ͠ͳ͍ɻͦΕͬΆ͍ͷ͍͘ ͔ͭ͋Δ͕ɺStoryboradͳͲϓϥοτϑΥʔϜ͕ఏڙ͢Δ ͷ͔Β֎ΕΔͷϦεΫ͕ߴ͍ • ͋ΔఔUIKit͕ޮΑ͘࠶ඳըͯ͘͠ΕΔ͕ɺ UITableViewͳͲΛ͏·ࠩ͘ߋ৽͢ΔΈ͕΄͍͠ • ࠓࣗͰஸೡʹࠩߋ৽Λߦ͏ํ
Τϥʔॲཧ • ActionͷPayloadͰErrorΦϒδΣΫτΛStoreʹ͠ɺStore ͕ঢ়ଶͱͯ͠อ࣋ • Τϥʔঢ়ଶΛม͑ΔActionͱͯ͠ѻ͏͖͔ • ͍·ͷSwiftFluxSwift2ͷthrowsΛ͏·͍͑ͯ͘ͳ͍
Ξχϝʔγϣϯ • ۪ʹΔͱFluxͷϑϩʔ͕େྔʹճΔ • Ξχϝʔγϣϯͷεςʔλεʢ։࢝ɺऴྃʣΛঢ়ଶͱͯ͠ѻ ͏͖͔ • JSͷํʑͲ͏ઃܭͯ͠ΔΜͰ͔͢Ͷʁ
ଞʹ͜͏͍͏ϥΠϒϥϦ ແ͍ͷʁ
ReSwift • https://github.com/ReSwift/ReSwift • Swift൛Reduxɻ࠷ۙ͞Ε͖ͯͯΔɻ • SwiftFluxͰStoreGroupΛ࡞ͬͯࣅͨΑ͏ͳ͜ͱΛΖ͏ ͱͯ͠Δ͚Ͳ͜Ε͔Β
ࢀߟϦϯΫ SwiftFluxͰෳࡶͳঢ়ଶͷมԽΛ༧ଌՄೳʹ͢ΔiOSΞϓϦ։ൃ http://qiita.com/yonekawa/items/c8a53d534084850963a3
ωΠςΟϒΞϓϦͷ ϑϩϯτΤϯυେมͰɻ