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
MVVMについて.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
keisukeYamagishi
November 28, 2021
500
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MVVMについて.pdf
keisukeYamagishi
November 28, 2021
More Decks by keisukeYamagishi
See All by keisukeYamagishi
RxAlert 結構便利だと思います。
keisukeyamagishi
0
210
Chart実装が楽になりました。
keisukeyamagishi
0
1.2k
NabigationControllerとの付き合い方
keisukeyamagishi
0
330
開発効率を考えてみました。xsort
keisukeyamagishi
0
330
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
160
Exploring anti-patterns in Rails
aemeredith
3
430
Balancing Empowerment & Direction
lara
6
1.2k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
How to Ace a Technical Interview
jacobian
281
24k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
350
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
320
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
Designing for Performance
lara
611
70k
Transcript
僭越ながら、 MVVM🤔 Input Output について考えてみました。 Shichimitoucarashi keisuke yamagishi
自己紹介 名前:山岸恵介 iOSエンジニア Github: https://github.com/keisukeYamagishi HP: https://sevens-api.herokuapp.com/
読みやすく、わかりやすく、管理しやすい コンセプトは
まずは ’Input’これは入力される値を渡すわけです が、工学的🧐 学術的🤔、そして抽象的🤩
わかりづらいと感じます🤓
受信🎉 わかりやすい気がします(主観ですが) なので、 ’Input’は Receive
`receive` で定義したサンプルコード protocol ViewModelReceive: AnyObject { func callApi(_ indexPath: IndexPath)
}
`Output` に関しても、工学的🧐、学術的 🤔、そして抽象的🎉
やっぱりこちらもわかりづらいと感じます😇
なので😇 例えばですが、 画面遷移を伴うものは、 `route` で定義 UIに変化を反映させる場合は、 `ui` で定義。
routeのサンプルコード protocol ViewModelRoute: AnyObject { func detail(_ result: @escaping (Data?,
String, HTTPURLResponse?, Error?) -> Void) func transition(_ callBack: @escaping () -> Void) }
uiのサンプルコード protocol ViewModelUI: AnyObject { func progress(_ handler: @escaping ((Float)
-> Void)) }
ViewController側の実装🦾 viewModel.route.detail { [unowned self] data, str, res, error in
self.detail(data: data, param: str, response: res, error: error) } viewModel.route.transition {[unowned self] in self.detailViewController(isDL: true) } viewModel.ui.progress { percentage in self.progressView.progress = percentage } viewModel.receive.callApi(indexPath)
まとめ この書き方については、「Nuke」の作者の「Alex Grebenyuk」のtweetをみて自分なりに作成してみまし た。 https://github.com/kean https://twitter.com/a_grebenyuk サンプルが下記になります。興味のある方はみていただけますと幸いです。 https://github.com/Jelly-and-removes/HttpSession/tree/feature/new-architectur e 使う人がわかりやすい事を念頭におく事が大事だと考えるので、このよう
な考え方は良いと考え、この場をお借りして、発言させていただきました。 皆様のご意見、ご感想をいただけますと非常に幸いでございます。 以上となります。
ご静聴いただき誠にありがとうございました。 🎉