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
複雑なアプリを Redux + MVVMで 完璧に制御する
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ANDPAD inc
April 07, 2021
Programming
360
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
複雑なアプリを Redux + MVVMで 完璧に制御する
2021/03/24 ANDPAD TechLive #8 iOS/AndroidアプリエンジニアTalk!!
ANDPAD inc
April 07, 2021
More Decks by ANDPAD inc
See All by ANDPAD inc
実行場所を意識させない i18n API を作った話
andpad
1
160
Go 1.27 における memory allocation の高速化
andpad
0
400
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
190
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
150
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
580
ANDPAD Ruby sponsor session in RubyKaigi 2026
andpad
0
270
AWS WAFの運用を地道に改善し、自社で運用可能にするプラクティス
andpad
2
1.3k
アプリから 360 度カメラ「RICOH THETA」に接続して写真を撮影する
andpad
0
95
アンドパッドが提供する Drinks and Local Meals と Drinkup を大公開
andpad
0
160
Other Decks in Programming
See All in Programming
setup-vp GitLab対応の裏側
naokihaba
0
110
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
200
wkhtmltopdfの次どうするか問題2026
willnet
2
1.5k
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
250
JRuby: Past, Present, and Future
headius
0
130
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
1
150
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
280
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2k
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
220
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
430
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
940
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Statistics for Hackers
jakevdp
799
230k
A Tale of Four Properties
chriscoyier
163
24k
30 Presentation Tips
portentint
PRO
1
400
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
Transcript
複雑なアプリを Redux + MVVMで 完璧に制御する Android/iOS/Flutter
自己紹介 柿森 隆生(Kakimori Takao) 2021/03/01 join Qiita: Urotea github: Urotea
興味のあるもの: rust, go, Flutter, Android, iOS, k8s, GCP, react 最近のトレンド: Flutter2.0面白そう 一言で表すなら: Redux芸人
宣伝 Android + Reduxアーキテクチャで状態管理が容易になった話 https://qiita.com/Urotea/items/8cbc8f55406b6ff32bbd Reduxの記事 on Qiita 本日の話でReduxに興味を持った方は是非
今回のお話 1 複雑なアプリはなぜ複雑なのか 2 複雑なものは抽象化して簡単にする 3 複雑なものをReduxで制御する 4 MVVMとReduxでアプリを制御する
結論 Reduxを使うと... - テストがしやすい - 複雑なアプリが整理される - 保守しやすくなる - レビューしやすい
0 Reduxって何?
アプリの状態管理に特化 したフレームワーク
引用: https://www.webopixel.net/javascript/1601.html 1. アプリ外部からのイベントが発火 2. 状態を書き換える 3. 状態が新しくなる 4. 画面に反映される
1 複雑なアプリはなぜ複雑なのか
複雑なアプリはなぜ複雑なのか 画面が多いから? 通信が多いから? 入力項目が多いから? 権限等ルールが多いから?
複雑なアプリはなぜ複雑なのか アプリの状態が複雑 画面が多いから 通信が多いから 入力項目が多いから? 権限等ルールが多いから
2 複雑なものは抽象化して簡単にする
アプリを抽象化して考える
アプリを抽象化して考える
これがアプリ
これがアプリ Action Action Action Action Action Reducer Reducer Reducer Reducer
Reducer State State State
3 複雑なものをReduxで制御する
Reduxで状態遷移を考える まずは簡単な状態遷移 State State Action Reducer
Reduxで状態遷移を考える まずは簡単な状態遷移 State State Action Reducer
これがRedux fun main(args: Array<String>) { val oldState = AppState(loggedIn =
false) val newState = loginReducer(oldState, Action.LoginCompleted) print(newState) } sealed class Action { object LoginCompleted: Action() {} } data class AppState(val loggedIn: Boolean) fun loginReducer(oldState: AppState, action: Action): AppState { return when(action) { is Action.LoginCompleted -> oldState.copy(loggedIn = true) } } State State Action Reducer
Reduxはテストが容易 fun main(args: Array<String>) { val oldState = AppState(loggedIn =
false) val newState = loginReducer(oldState, Action.LoginCompleted) print(newState) } sealed class Action { object LoginCompleted: Action() {} } data class AppState(val loggedIn: Boolean) fun loginReducer(oldState: AppState, action: Action): AppState { return when(action) { is Action.LoginCompleted -> oldState.copy(loggedIn = true) } } ただのオブジェクト ただのオブジェクト ただの純関数
まとめ アプリとは状態遷移機械である
まとめ Reduxは状態遷移機械を 記述するフレームワーク middlewareなどの細かい話は別の機会に
あれ?Viewはどこにいった?
Reduxは状態遷移機械を 記述するフレームワーク
Viewは専門外 別の仕組みでなんとかする!
4 MVVMとReduxでアプリを制御する
MVVM Model-View-ViewModel
MVVM 引用: https://developer.android.com/jetpack/guide?hl=ja View ViewModel Model
MVVM View ViewModel Model 画面を操作する場所 画面の状態を管理する場所 それ以外 - API通信 -
DB永続化 - ビジネスロジック
MVVM Viewを跨ぐ状態はどうする?
MVVM Viewに現れない状態はどうする?
MVVM View以外は専門外 別の仕組みでなんとかする!
MVVM + Redux Redux
MVVM Reduxを抽象化 oldState newState Action Reducer subscribe(Rx or coroutine) data
binding Redux
MVVM Reduxの具体例 oldState newState Action Reducer subscribe(Rx, coroutine) data binding
Redux View ViewModel Reducer ログインボタン クリック ログイン Action ログイン 完了状態 ・ボタンAを非表示 ・テキストBを表示
実際の言語ではどうする? iOS: ReSwift, RxSwift, RxCocoa Android: ReKotlin, Coroutine, DataBinding Flutter:
flutter_redux
詳しくは こんな所にReduxの記事とリポジトリが! Qiita: https://qiita.com/Urotea/items/8cbc8f55406b6ff32bbd Github: https://github.com/Urotea/flutter_template, https://github.com/Urotea/flutter_nfc_sample, https://github.com/Urotea/android-sample-app
で、実際のところどうなの? Q: プロダクションでの活用事例は? A: 開発人数2人。期間3カ月。WebViewやセンサに触りまくるアプリで実績あります。 Reduxに助けられっぱなしでした(ので、今話してます)。 Q: どのくらいの規模から使用したほうがよい? A: 保守しないなら不要。それ以外では検討価値あり。
Q: メリットは分かった。デメリットは? A: 初期学習コストが少々高い。Redux + Rx + モバイル特有の知識が要求される。 Q: Reduxって記述量やファイル数が増えて大変じゃない? A: 記述量が多いことはコーディングにおいて大した問題じゃない。 役割ごとにファイルが分割されることは gitを前提にするとメリット。