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
AbemaTVにおけるiOSアーキテクチャの課題解決 / Solving problems i...
Search
Yusuke Morishita
January 30, 2020
Technology
1
1.6k
AbemaTVにおけるiOSアーキテクチャの課題解決 / Solving problems in AbemaTV iOS architecture
AbemaTV iOSの5年の運用の中で発生した設計課題とその解決方法について
Yusuke Morishita
January 30, 2020
Tweet
Share
Other Decks in Technology
See All in Technology
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Platform Engineering for Software Developers and Architects
syntasso
1
520
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
強いチームと開発生産性
onk
PRO
35
11k
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
140
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
170
組織成長を加速させるオンボーディングの取り組み
sudoakiy
2
210
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
DynamoDB でスロットリングが発生したとき_大盛りver/when_throttling_occurs_in_dynamodb_long
emiki
1
430
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
Optimizing for Happiness
mojombo
376
70k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Statistics for Hackers
jakevdp
796
220k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
We Have a Design System, Now What?
morganepeng
50
7.2k
Practical Orchestrator
shlominoach
186
10k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
How STYLIGHT went responsive
nonsquared
95
5.2k
Agile that works and the tools we love
rasmusluckow
327
21k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Transcript
"CFNB57ʹ͓͚Δ J04ΞʔΩςΫνϟͷ՝ղܾ .77. 6OJP 'MVY :VTVLF.PSJTIJUB!ZZTTLL "CFNB57։ൃہωΠςΟϒج൫
"HFOEB wϓϩμΫτഎܠ wઃܭͷมભ wݱࡏͷ՝
ϓϩμΫτഎܠ
ϓϩμΫτഎܠ w݄͔Β։࢝ͯ͠ݱࡏ wݱࡏ໊Ͱ։ൃ wϨϙδτϦ wJ04"QQ "1*ΫϥΠΞϯτ ϩάͷϞσ ϧʜFUD
ϓϩμΫτഎܠνʔϜਓ ࣌ؒ ਓ ্ཱͪ͛࣌
ઃܭͷมભ
ઃܭͷมભ wୈ̍ੈ'MVY wୈ̎ੈ.77. 'MVY wୈ̏ੈ.77. 6OJP 'MVY
ઃܭͷมભ$POUSJCVUJPOHSBQI ୈ̍ੈ ୈ̎ੈ ୈ̏ੈ
ઃܭͷมભ$POUSJCVUJPOHSBQI ୈ̍ੈ ୈ̎ੈ ୈ̏ੈ ॎԽɺϏσΦػೳ։࢝
ઃܭͷมભ$POUSJCVUJPOHSBQI ୈ̍ੈ ୈ̎ੈ ୈ̏ੈ ΞϓϦίΠϯɺ͛મػೳ։࢝
ઃܭͷมભνʔϜਓ ࣌ؒ ਓ ୈ̍ੈ ୈ̎ੈ ୈ̏ੈ
ୈ̍ੈ w࣌ظ wॳظϦϦʔε w.PUJWBUJPO wෳࡶͳঢ়ଶཧΛΘ͔Γ͘͢ཧ͍ͨ͠ wΫϥΠΞϯτؒ "OESPJEJ048FC ͰઃܭΛ౷Ұͨ͠ ͍
࠾༻'MVY 3Y4XJGU Facebook https://facebook.github.io/flux/docs/in-depth-overview/
ୈ̍ੈ'MVY 6*Πϕϯτ ঢ়ଶΛࢹͯ͠6*ө
ୈ̍ੈ"DUJPO func getElement() { dispatcher.isLoading.dispatch(true) APIClient.getElement() .do(onError: { [weak self]
error in self?.dispatcher.error(error) // Τϥʔ }) .do(onCompleted: { [weak self] in self?.dispatcher.isLoading.dispatch(false) // ྃ }) .subscribe(onNext: { [weak self] element in self?.dispatcher.element.dispatch(element) // ޭ }) .disposed(by: disposeBag) }
ୈ̍ੈ%JTQBUDIFS final class Dispatcher { static let shared = Dispatcher()
let element = DispatchSubject<Element>() let isLoading = DispatchSubject<Bool>() let error = DispatchSubject<Error>() }
ୈ̍ੈ4UPSF final class Store { static let shared = Store()
let isLoading: Property<Bool> let element: Property<Element> init(dispatcher: Dispatcher) { // dispatcher͔ΒྲྀΕ͖ͯͨΠϕϯτΛbind͢Δ } }
ୈ̍ੈ6* override func viewDidLoad() { super.viewDidLoad() // ActionʹΠϕϯτΛൃՐ Action.shared.getElement() //
ߋ৽͞Εͨঢ়ଶΛUIʹbind Store.shared.element.asObservable() .bind(to: titleLabel.rx.text) .diposed(by: disposeBag) }
ୈ̍ੈ'MVY 6*Πϕϯτ ঢ়ଶΛࢹͯ͠6*ө
ୈ̍ੈͷྑ͍ w7JFXؒͷґଘ͕ؔݮΔ w։ൃऀͷ࣮͕౷Ұ͞Ε͍͢ wσʔλͷྲྀΕ͕Θ͔Γ͍͢
ୈ̎ੈ w ࣌ظ w ݄dλςରԠͷ։ൃ։࢝ w ݄dϏσΦػೳͷ։ൃ։࢝
ୈ̍ੈͷ՝ w ػೳͷෳࡶԽʹΑΓɺ4UPSF6*ͷϥΠϑ αΠΫϧͷ߹ϩδοΫ͕7JFX$POUSPMMFS ʹ૿͑ͨ
ୈ̍ੈͷ՝ override func viewDidLoad() { super.viewDidLoad() // ঢ়ଶͷߋ৽·ͨλςϤίͷΓସ͑ΛϑοΫͯ͠tableViewΛϦϩʔυ Observable.combineLatest( Store.shared.repositories.asObservable(),
rx.traitCollectionDidChange.asObservable() ) .observeOn(MainScheduler.instance) .subscribe(onNext: { [weak self] _ in self?.tableView.reloadData() }) .disposed(by: disposeBag) … }
࠾༻.77. 7JFX.PEFM .PEFM 7JFX 7JFX$POUSPMMFS %BUBCJOEJOH
ୈ̎ੈ7JFX4USFBN
ୈ̎ੈ7JFX4USFBN final class ViewStream { // Output let element: Property<Element>
let isLoading: Property<Bool> init( // Input viewDidLayout: Observable<Void>, traitCollectionDidChange: Observable<Void>, // Dependency action: Action = .shared, store: Store = .shared ) { // InputͷΠϕϯτΛͱʹOutputΛ߹͢Δ } }
ୈ̎ੈͷྑ͍ w7JFX$POUSPMMFSͷ࣮Λ6*Πϕϯτͷൖͱঢ়ଶ Λ6*ʹόΠϯυ͢ΔͷΈʹͰ͖ͨ wϓϨθϯςʔγϣϯϩδοΫΛ6*͔ΒͰ͖ɺ ୯ମςετָ͕ʹ͔͚Δ wάϩʔόϧͰอ࣋͢Δඞཁ͕ͳ͍ը໘ͷҰ࣌ঢ়ଶ Λ6*ͷϥΠϑαΠΫϧͰഁغͰ͖Δ
ઃܭͷมભνʔϜਓ ࣌ؒ ਓ ୈ̍ੈ ୈ̎ੈ ୈ̏ੈ
ୈ̎ੈͷ՝ w 7JFX4USFBNͷ࣮ํ๏͕࣮ऀʹΑͬͯ Β͖͕ͭ͋Δ
ୈ̎ੈͷ՝ class SearchViewStream { // Output let repositories: Property<[Repository]> private
let _repositories = BehaviorRelay<[Repository]>(value: []) private let _search = PublishRelay<String>() private let disposeBag = DisposeBag() init( // Dependency action: Action = .shared store: Store = .shared ) { // Input ⇨ Output Logic } // Input func search(_ text: string) { _search.accept(text) } }
ୈ̎ੈͷ՝ class SearchViewStream { // Output let repositories: Property<[Repository]> private
let _repositories = BehaviorRelay<[Repository]>(value: []) private let _search = PublishRelay<String>() private let disposeBag = DisposeBag() init( // Dependency action: Action = .shared store: Store = .shared ) { // Input ⇨ Output Logic } // Input func search(_ text: string) { _search.accept(text) } }
ୈ̎ੈͷ՝ class SearchViewStream { // Output let repositories: Property<[Repository]> private
let _repositories = BehaviorRelay<[Repository]>(value: []) private let disposeBag = DisposeBag() init( // Input search: Observable<String> // Dependency action: Action = .shared store: Store = .shared ) { // Input ⇨ Output Logic } }
ୈ̎ੈͷ՝ class SearchViewStream { // Input let search = PublishRelay<String>()
// Output let repositories: Property<[Repository]> private let _repositories = BehaviorRelay<[Repository]>(value: []) private let _search = PublishRelay<String>() private let disposeBag = DisposeBag() init( // Dependency action: Action = .shared store: Store = .shared ) { // Input ⇨ Output Logic } }
ߟҊ6OJP $SFBUFECZNBSUZTV[VLJ
ୈ̏ੈ w ࣌ظ w "CFNBίΠϯػೳͷ։ൃ w "CFNBαϙʔτ ͛મ ػೳͷ։ൃ
ୈ̏ੈ6OJP class SearchViewModel: UnioStream<SearchViewModel>, SearchViewModelType { struct Input: InputType {
let search = PublishRelay<String>() } typealias State = NoState struct Output: OutputType { let repositories: Observable<[Repository]> } struct Extra: ExtraType { let action: Action let store: Store } static func bind(from dependency: Dependency<Input, State, Extra>, disposeBag: DisposeBag) -> Output { // Dependency ⇨ Output Logic return Output(repositories: ${repositoriesΛฦ͢ม}) } }
ୈੈͷྑ͍ w7JFX.PEFMͷ࣮ͷ౷Ұ͕࣮ݱͰ͖ͨ w7JFX.PEFMͷϩδοΫͷྲྀΕ͕୯Ұํͳ ͷͰՄಡੑ্͕͕ͬͨ
ୈ̏ੈ6OJP
ݱࡏͷ՝
ݱࡏͷ՝ wਐԽ͍ͯ͘͠աఔͰલੈͷ࣮͕͍ͬͯΔ wୈ̍ੈͷ࣮ͰҰ෦'MVYͰ4UPSFUP4UPSF ͳ࣮ʹͳ͍ͬͯͯॲཧͷྲྀΕ͕ෳࡶԽ͍ͯ͠Δ wը໘ͷ୯ମىಈ͕Ͱ͖ͳ͍࣮ʹͳ͍ͬͯΔ w'MVYͷ"DUJPO͕3FTPVSDFࢀর͍ͯ͠Δ
·ͱΊ wઃܭͷมߋͷλΠϛϯάશػೳΛ৽͢ Δͱ͖େ͖ͳػೳ։ൃ͕ೖΔͱ͖ wॳظͷίϯηϓτ͔Βൃੜͨ͠՝ʹରͯ͠ ղܾ͢Δํ๏Λ৽ͨ͠ʹऔΓೖΕͯมԽ ͖ͯͨ͠
ࢀর w 'MVYXJUI3Y4XJGU w IUUQTTQFBLFSEFDLDPNEFLBUPUPSPqVYXJUISYTXJGU w .77. 'MVY w IUUQTTQFBLFSEFDLDPNNBSUZTV[VLJNWWNQMVTqVY
w "CFNBJ04"SDIJUFDUVSF w IUUQTTQFBLFSEFDLDPNUPJLJBCFNBJPTBSDIJUFDUVSF w 6OJP w IUUQTTQFBLFSEFDLDPNNBSUZTV[VLJNWWNGBMTFTIJ[IVBOHXPGVSVGSBNFXPSLXPLBJGBEBP SVTJUJNVEFCBSBUVLJHBBUVUBTIJ[IVBOHXPUPOHTVSV