Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
マッチングアプリにつきまとう状態管理のつらさ/torte_state
Search
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
170
新しい恋愛様式への挑戦/engineer_career_design_week
corin8823
0
200
安心安全な開発にむけて/matching-dev-meetup-5
corin8823
0
480
Bad practice for tax hike handling
corin8823
0
630
Practice of build and CI/CD at tapple/practice_of_build_at_tapple
corin8823
1
290
「タップル誕生」における開発の変化 / change_development
corin8823
1
480
明日から使えるViewControllerの Memory Leak検出/iOSDC-2018-Memory-Leak
corin8823
6
2.8k
Introduction Differ/differ
corin8823
0
3.8k
Other Decks in Technology
See All in Technology
Making AI Agents Safe and Fast- Jev, Obsidian, and the Meta-Harness
x5gtrn
PRO
0
120
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
270
beyond jj: config & tools ecosystem
indirect
0
5.8k
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
3
2.1k
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
30
19k
データ界隈LT祭 第1回LT登壇
taromatsui_cccmkhd
2
1.5k
え、こんなに早く改修できるの?──新人エンジニアとスクラムマスターの2人が語る、AI×アジャイル開発の現場
ysasago
2
670
銀行勘定系システムにおける開発プロセス刷新×AIによる環境モダナイゼーション / Development Process Transformation and AI-Driven Environment Modernization
muit
1
2.6k
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.6k
データ_AIの事業の勝敗をわけるもの
nek0128
1
470
Oracle Cloud Infrastructure(OCI):Onboarding Session(はじめてのOCI/Oracle Supportご利⽤ガイド)
oracle4engineer
PRO
2
20k
.NET WebAssemblyで実現するクライアントサイドAI推論:NuGetからViteまで、2つのエコシステムを繋ぐビルド戦略
yamachu
1
510
Featured
See All Featured
Being A Developer After 40
akosma
91
590k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
GraphQLとの向き合い方2022年版
quramy
50
15k
Making Projects Easy
brettharned
120
6.8k
Into the Great Unknown - MozCon
thekraken
41
2.7k
Building an army of robots
kneath
307
46k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
Utilizing Notion as your number one productivity tool
mfonobong
4
590
A Soul's Torment
seathinner
8
3.6k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
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