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
マッチングアプリにつきまとう状態管理のつらさ/torte_state
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
corin8823
October 18, 2017
Technology
7.4k
9
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
マッチングアプリにつきまとう状態管理のつらさ/torte_state
corin8823
October 18, 2017
More Decks by corin8823
See All by corin8823
検証と資産化を形にするプロダクト組織へ/tapple_pmconf2024
corin8823
2
17k
経済学の知見を活かしたユーザに行動変容を促す仕掛け - タップルでの共同研究プロジェクトを例として
corin8823
1
160
新しい恋愛様式への挑戦/engineer_career_design_week
corin8823
0
190
安心安全な開発にむけて/matching-dev-meetup-5
corin8823
0
470
Bad practice for tax hike handling
corin8823
0
610
Practice of build and CI/CD at tapple/practice_of_build_at_tapple
corin8823
1
280
「タップル誕生」における開発の変化 / change_development
corin8823
1
470
明日から使えるViewControllerの Memory Leak検出/iOSDC-2018-Memory-Leak
corin8823
6
2.7k
Introduction Differ/differ
corin8823
0
3.8k
Other Decks in Technology
See All in Technology
自分が詳しくない領域でAIを使う #プロヒス2026
konifar
20
7.4k
AIチャット検索改善の3週間
kworkdev
PRO
2
170
[AWS Summit Japan 2026]迷っているあなたへ_小さな一歩が、やがて自分を助けてくれる
sh_fk2
2
410
飲食店もAIで。レジ締めやハンディシステムをつくってる話 / Using AI for restaurant management
vtryo
0
170
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
430
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
200
新しいUbuntu/GNOMEが使いたいからXからWaylandへ移行頑張ってるの巻 2026-06-20
nobutomurata
0
160
レガシーな広告配信システムでのAI駆動開発/運用の挑戦
i16fujimoto
0
120
【セミナー資料】Claude Code をセキュアに使うための考え方と設定の勘どころ / Claude Code Webinar 20260616
masahirokawahara
2
470
脱SaaS!FDEを支えるプロビジョニングと分離設計
knih
0
300
ぼっちではじめた登壇が「51名」「241件」の発信に化けた
subroh0508
1
310
クレデンシャル流出 ― 攻撃 3 時間 vs 復旧 10 時間。この非対称性にどう備えるか
kazzpapa3
3
560
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
Optimizing for Happiness
mojombo
378
71k
Designing for Performance
lara
611
70k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
610
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
The SEO Collaboration Effect
kristinabergwall1
1
490
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
How to Ace a Technical Interview
jacobian
281
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
220
Prompt Engineering for Job Search
mfonobong
0
350
Transcript
ϚονϯάΞϓϦʹ͖ͭ·ͱ͏ঢ়ଶཧͷͭΒ͞ ߴڮ ༏հ @corin8823 גࣜձࣾτϧς / Developer 2017.10.18 CA.SWIFT #4
ߴڮ ༏հ yusuke takahashi גࣜձࣾτϧς / Developer 2013৽ଔೖࣾ corin8823 @corin8823
ࣗݾհ
IUUQTTXFFUUPSUFDPN ࡀҎ্ݶఆ
ϚονϯάΞϓϦʹ͖ͭ·ͱ͏ ঢ়ଶཧͷͭΒ͞
7JFX$POUSPMMFSΛ ލ͍ͩঢ়ଶཧ
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ ߘ༰ ະಡطಡ ભҠ
w ৄࡉͰʮ͍͍Ͷʯͨ࣌͠ʹҰཡͷө w "λϒͰʮ͍͍Ͷʯͨ࣌͠ʹ#λϒͰͷө w ৄࡉͰআͨ࣌͠ʹҰཡ͔Βফ͢ w ʑ 7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ
લճͷొஃࢿྉ
IUUQTGBDFCPPLHJUIVCJPqVYEPDTJOEFQUIPWFSWJFXIUNMDPOUFOU 'MVY
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ ߘ༰ ະಡطಡ ભҠ
final class TopAction { enum Item { case load case
error } private let dispatcher: Dispatcher init(dispatcher: Dispatcher = .shared) { self.dispatcher = dispatcher } func loadItem() { let req = API.ItemRequest() Session.send(req) { result in switch result { case .success(let items): self.dispatcher.dispatch(obj: items, key: Item.load) case .failure(let error): self.dispatcher.dispatch(obj: error, key: Item.error) } } } }
final class TopStore { private(set) var items = Variable<[Item]>([]) private(set)
var error = PublishSubject<Error>() init(dispatcher: Dispatcher = .shared) { dispatcher.register(observer: self, key: TopAction.Item.load) { [weak self] (items: [Item]) in self?.items.value = items } dispatcher.register(observer: self, key: TopAction.Item.error) { [weak self] (error: Error) in self?.error.on(.next(error)) } } }
final class TopViewController: UIViewController { @IBOutlet weak var tableView: UITableView!
private let store = TopStore() private let disposeBag = DisposeBag() override func viewDidLoad() { super.viewDidLoad() self.store.error .bind { _ in // error handling } .disposed(by: self.disposeBag) self.store.items .asObservable() .bind { [weak self] _ in self?.tableView.reloadData() } .disposed(by: self.disposeBag) TopAction().loadItem() } }
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ ߘ༰ ະಡطಡ ભҠ
final class TopDetailAction { enum ItemDetail { case update case
error } func update(itemId: Int64) { let req = API.UpdateItemRequest(itemId: id) Session.send(req) { result in switch result { case .success(let item): self.dispatcher.dispatch(obj: item, key: ItemDetail.update) case .failure(let error): self.dispatcher.dispatch(obj: error, key: update.error) } } } }
final class TopDetailAction { enum ItemDetail { case update case
error } enum Item { case update } func update(itemId: Int64) { let req = API.UpdateItemRequest(itemId: id) Session.send(req) { result in switch result { case .success(let item): self.dispatcher.dispatch(obj: item, key: ItemDetail.update) self.dispatcher.dispatch(obj: item, key: Item.update) case .failure(let error): self.dispatcher.dispatch(obj: error, key: update.error) } } } }
final class TopStore { private(set) var items = Variable<[Item]>([]) private(set)
var error = PublishSubject<Error>() init(dispatcher: Dispatcher = .shared) { dispatcher.register(observer: self, key: TopAction.Item.load) { [weak self] (items: [Item]) in self?.items.value = items } dispatcher.register(observer: self, key: TopAction.Item.error) { [weak self] (error: Error) in self?.error.on(.next(error)) } dispatcher.register(observer: self, key: TopDetailAction.Item.update) { [weak self] (item: Item) in if let i = self?.items.value.findFirstIndex ({ $0.id == item.id }) { self?.items.value[i] = match } } } }
final class TopViewController: UIViewController { @IBOutlet weak var tableView: UITableView!
private let store = TopStore() private let disposeBag = DisposeBag() override func viewDidLoad() { super.viewDidLoad() self.store.error .bind { _ in // error handling } .disposed(by: self.disposeBag) self.store.items .asObservable() .bind { [weak self] _ in self?.tableView.reloadData() } .disposed(by: self.disposeBag) TopAction().loadItem() } }
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ 5PQ7JFX$POUSPMMFS 5PQ4UPSF 5PQ"DUJPO %JTQBUDIFS
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ 5PQ%FUBJM7JFX$POUSPMMFS 5PQ%FUBJM4UPSF 5PQ%FUBJM"DUJPO %JTQBUDIFS
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ 5PQ7JFX$POUSPMMFS 5PQ%FUBJM7JFX$POUSPMMFS 5PQ4UPSF 5PQ%FUBJM4UPSF 5PQ%FUBJM"DUJPO %JTQBUDIFS
ߘͷঝೝ
ߘͷঝೝ Ϣʔβʔ ঝೝऀ αʔόʔ ߘ ཧը໘
ߘͷঝೝ Ϣʔβʔ ঝೝऀ αʔόʔ ঢ়ଶө ঝೝ
w ྸ֬ೝ w χοΫωʔϜ w ࣸਅߘ w ࠷ॳͷϝοηʔδ w ঁੑ͔ΒͷΫνίϛ
ঝೝ͕ඞཁͳߘ
ߘͷঝೝ Ϣʔβʔ ঝೝऀ αʔόʔ ঢ়ଶө ঝೝ
w Ͱ͖Δ͚ͩૣ͘ঝೝΛ͍͑ͨ w ৭ʑͳঝೝ͕͋Δ ࠓޙ૿͑ΔՄೳੑ w ঝೝऔಘ"1*ΛϙʔϦϯά ʀТʀʆ ŲƄƂŕ
w 8FC4PDLFUுΔʁ w ΤϯδχΞ࠷খݶͰ ߘͷঝೝͷ
'JSFCBTF3FBMUJNF%BUBCBTF IUUQTpSFCBTFHPPHMFDPNQSPEVDUTSFBMUJNFEBUBCBTF
IUUQTpSFCBTFHPPHMFDPN 'JSFCBTF
w ϦΞϧλΠϜ w ΦϑϥΠϯ w ΫϥΠΞϯτ͔ΒΞΫηεՄೳ 'JSFCBTF3FBMUJNF%BUBCBTF IUUQTpSFCBTFHPPHMFDPNEPDTEBUBCBTF
ߘͷঝೝϑϩʔ Ϣʔβʔ ঝೝऀ αʔόʔ ঢ়ଶө ঝೝ 4ZOD
w VTFST\VTFS@JEతͳ^CBEHF ۩ମྫ class Badge { var notification: Int var
match: Int var message: Int } w OPUJpDBUJPO͕૿͑ͨΒ࠶ࣗΛऔಘ w NBUDI͕૿͑ͨΒϚονͷϦετΛߋ৽ w NFTTBHF͕૿͑ͨΒόοδΛ͚ͭͯɾɾ
'JSFCBTF3FBMUJNF%BUBCBTFΛͬͨߘͷঝೝ Ϣʔβʔ αʔόʔ 4ZOD ঝೝ
'JSFCBTF3FBMUJNF%BUBCBTFΛͬͨߘͷঝೝ Ϣʔβʔ αʔόʔ όοδΛΠϯΫϦϝϯτ 4ZOD ঝೝ
'JSFCBTF3FBMUJNF%BUBCBTFΛͬͨߘͷঝೝ Ϣʔβʔ αʔόʔ όοδΛΠϯΫϦϝϯτ 4ZOD ঝೝ "1*ίʔϧ
"1*Λୟ͘τϦΨʔ͚ͩΛ 'JSFCBTF3FBMUJNF%BUBCBTFʹ
w ճ͔͑͠ͳ͍ػೳͷΛ͍ΕͨΓ w "1*ୟ͘લʹ7JFXʹө͍ͤͨ͞ w "1*ୟ͘·Ͱͳ͍ ߘͷঝೝҎ֎ʹ
w ճ͔͑͠ͳ͍ػೳͷΛ͍ΕͨΓ w "1*ୟ͘લʹ7JFXʹө͍ͤͨ͞ w "1*ୟ͘·Ͱͳ͍ ߘͷঝೝҎ֎ʹ w ΞΠςϜͷಉظͨ͘͠ͳΔ
w ճ͔͑͠ͳ͍ػೳͷΛ͍ΕͨΓ w "1*ୟ͘લʹ7JFXʹө͍ͤͨ͞ w "1*ୟ͘·Ͱͳ͍ ߘͷঝೝҎ֎ʹ w ΞΠςϜͷಉظͨ͘͠ͳΔ w
͋Ε͜Εɻɻɻ IUUQGVSBOEPOQJHHJUIVCJPGQJH@TBNQMFIPCCZCBE@TQJSBM
·ͱΊ
·ͱΊ ViewControllerΛލ͍ͩঢ়ଶཧ Firebase Realtime DatabaseΛͬͨߘͷঝೝ
7JFX$POUSPMMFSΛލ͍ͩঢ়ଶཧ 5PQ7JFX$POUSPMMFS 5PQ%FUBJM7JFX$POUSPMMFS 5PQ4UPSF 5PQ%FUBJM4UPSF 5PQ%FUBJM"DUJPO %JTQBUDIFS
'JSFCBTF3FBMUJNF%BUBCBTFΛͬͨߘͷঝೝ Ϣʔβʔ ঝೝऀ αʔόʔ ঢ়ଶө ঝೝ 4ZOD
5)"/,:06