module.exports = function (model, view, intent) {
if (view) { view.observe(model); }
if (intent) { intent.observe(view); }
if (model) { model.observe(intent); }
};
The first thing to notice is regarding the communication, as you can see from the schema above the communication is unidirectional.
In MVI, the view is exposing an observable for the intent to capture all the user interactions from the view and passing the data through an observable to the intent. The intent is preparing the data received for the model, and these data are passed to the model via an observable again. Last but not least the model save these data and update the view exposing an observable to the view.
The view is not changing directly, but it’s just preparing the virtual tree to be rendered by any renderer.
Bear in mind that one peculiarity of an MVI architecture is that an object shouldn’t manipulate or directly call any method of another object; the only communication allowed are through observables!
The unidirectional data flow nature allows easily to structure and debug any application without following the complexity of a traditional event-driven architectures.
What Developers need to know about MVI
The New Stack - Luca Mezzalira
MVI on Android
Medium.com
Android Clean Architecture MVI Boilerplate
GitHub
Comments
Post a Comment