Skip to content

A food ordering app sample demonstrating mvi with compose

Notifications You must be signed in to change notification settings

mahmed1987/FoodOrderSimulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Food ordering simulation

A demo showcasing how to use compose in an MVI styled application

This application showcases how the model view intent design paradigm works with compose as the UI framework of choice. We will start off by defining as simply as possible , the basic dogma behind MVI

MVI

MVI is an abbreviation for Model-View-Intent , a design paradigm in which the system is broken down into the three aforementioned parts. Each part has a specific responsibility as detailed below

Model

Contains the state of the system/screen/ui element. In the context of this application the model would be OrderUiState

View

The model above drives two views namely , OrderScreen.kt and OrderDetailsScreen.kt

Intentions

The follow intentions mutate the state of the view represented by OrderIntention

  • AddOrderToQueue (Adds the order to the order queue)
  • AdvanceStatus (Advances the status of the order ,for example from New -> Preparing)
  • RemovedDeliveredOrder (Removes the order from the queue after 15 seconds have elapsed)

How are intentions turned into State?

The convention is to use a function called "reduce", that takes an old state , and the new intention , and mutates the state. Take a look at the reduce function in the 'OrdersViewModel

About

A food ordering app sample demonstrating mvi with compose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages