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 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
Contains the state of the system/screen/ui element. In the context of this application the model
would be OrderUiState
The model above drives two views namely , OrderScreen.kt
and OrderDetailsScreen.kt
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)
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