Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
関数実行の裏側では何が起きているのか?
minop1205
1
380
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
370
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
590
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
170
無秩序からの脱却 / Emergence from chaos
nrslib
2
11k
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
200
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
手が足りない!兼業データエンジニアに必要だったアーキテクチャと立ち回り
zinkosuke
0
190
大体よく分かるscala.collection.immutable.HashMap ~ Compressed Hash-Array Mapped Prefix-tree (CHAMP) ~
matsu_chara
1
190
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
150
JJUG CCC 2025 Fall: Virtual Thread Deep Dive
ternbusty
3
510
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
110
Featured
See All Featured
Become a Pro
speakerdeck
PRO
30
5.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
990
For a Future-Friendly Web
brad_frost
180
10k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
GitHub's CSS Performance
jonrohan
1032
470k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Site-Speed That Sticks
csswizardry
13
980
Typedesign – Prime Four
hannesfritz
42
2.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
It's Worth the Effort
3n
187
29k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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