One Page

Model View Intent (MVI) Cheat Sheet

July 24, 2019

Event -> (processing) -> Result -> State or Event -> (processing) -> Effect

Events

Events define user actions. These may or may not carry additional data.

Eg: ScreenLoad, FabClick, AddItem

Results

Results are one element of state that persist

They are received by some action and you’d want them to remain present for a while and only disappear on some other event/action. They don’t represent the entire state, they’re usually the result of querying and you’d want to use them to incorporate into the state.

Eg: The result of a query asking for movies. The list of movies is the result. The profile object that’s been loaded from the server/database.

Effect

A transitory thing that should happen and then go away. These never go into state, unlike results. The effect is handled directly by whatever does view actions.

Eg: A toast that could be shown when a server request fails. There’s no point putting it in state because it would have to be put and then removed right away.

Eg: Opening a new screen.


This will be updated with “Putting them together”

Have suggestions for a topic I should cover? Send me a dm at @AniketSMK or email me at hello@[firstname][lastname].com


Aniket Kadam, author

Written by Aniket Kadam - building useful things. Follow me on Twitter