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
MVI (Model-View-Intention)
Search
Kapil Rathore
February 29, 2020
Programming
1
74
MVI (Model-View-Intention)
Presented on 29 February 2020 at Swift India.
https://www.meetup.com/Swift-Delhi/events/268573479/
Kapil Rathore
February 29, 2020
Tweet
Share
Other Decks in Programming
See All in Programming
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
130
並行開発のためのコードレビュー
miyukiw
0
180
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
CSC307 Lecture 04
javiergs
PRO
0
660
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
730
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
200
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
CSC307 Lecture 02
javiergs
PRO
1
780
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
Implementation Patterns
denyspoltorak
0
290
Oxlint JS plugins
kazupon
1
960
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
200
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
66
Designing for humans not robots
tammielis
254
26k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
0
140
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.9k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Building Adaptive Systems
keathley
44
2.9k
Designing for Timeless Needs
cassininazir
0
130
Transcript
Kapil Rathore iOS @ Tokopedia MVI (Model-View-Intention) Reactive Unidirectional Architecture
for your Apps @krkapilrathore @krkapilrathore @kapilrathore
What are you doing this weekend ? ♂
♂ I’m attending Swift Delhi Meetup
♂ Should I also join ?
♂ Sure, it’ll be fun !!
♂
♂ ⌨ INPUT OUTPUT OUTPUT INPUT
♂ ⌨ View ( ) User ( ) Model (
) Intention ( )
user ( )
intention ( user ( ) )
model ( intention ( user ( ) ) )
view ( model ( intention ( user ( ) )
) )
view ( model ( intention ( ) ) )
Pure Functions
Pure Functions ✅ ❌
Intention • Take the inputs from the user • Map
the user inputs to Model friendly events • Eg - button click events, text input events etc.
Model • Take the inputs from Intention • Processes a
particular business Usecase based on the input • Produces a New State as an output • Only piece of code that is allowed to change the State
• Immutable data structure • Holds all the important information
required to change the dynamic data on the UI layer • Acts as the single source of truth State
• Takes the output State produced by the Model as
input • Contains the rendering logic for the emitted state View
Rx Operators that we are going to use
Observable Sequence
None
None
None
Talk is cheap. Show me the code. - Linus Torvalds
Example App Counter MVI
Planning Intentions • Increment • Decrement • Reset Counter •
Interval Change
Code Intentions
Planning State • Count Value • Interval
Code State
Planning Model Usecases • Increment Usecase • Decrement Usecase •
Reset Counter Usecase • Interval Change Usecase
Code Increment Usecase
Code State
Code Decrement Usecase
Code Reset Counter Usecase
Code Interval Change Usecase
Intention View Different Model Usecases
BIND function - Model
Code View
Glue Code Outlets
Glue Code Initialize MVI Components
Glue Code Binding the MVI Components
Glue Code Implement the View Layer
Live Preview in Simulator
Summary Pros • Unidirectional & Cyclic Flow of Data •
Decoupled Code • Predictable (Pure functions + Immutable States) • Highly Testable & Debuggable (Encourages TDD) • User Centric (User drives the architecture) • Reactive (Handles the async code) • Platform Agnostic (Cross platform collaboration)
Summary Cons • Lots of Boilerplate • Where to place
navigation logic • Complexity (Learning Curve)
What’s Next + Combine Cook MVI using SwiftUI and Combine
References • What if the user was a function? by
Andre Staltz at JSConf Budapest 2015 • Managing State with RxJava by Jake Wharton • Mobius by Spotify • MVI Series: A Pragmatic Reactive Architecture for Android
Kapil Rathore iOS @ Tokopedia Questions @krkapilrathore @krkapilrathore @kapilrathore
Kapil Rathore iOS @ Tokopedia Thank You @krkapilrathore @krkapilrathore @kapilrathore