Hi guys, just a quick question. If i pass a variab...
# android-architecture
j
Hi guys, just a quick question. If i pass a variable from the model to view via presenter. Does it violate the rules of MVP? Thanks!
a
This idea "smells" a bit 🤷
Maybe if you describe the use case people can suggest a better way
s
View should only get state/data which it can directly show to the user. So when you pass data from model to presenter, you transform that data to either a particular UI state or something that can be directly used by the view to render.
👆 3
j
Got this
Thanks guys! @Anastasia Finogenova @Sagar Suri
i
Instead of passing a reference to the View from presenter you could use the Observer pattern to react to changes in the data. We're currently using the latest from Architecture Components (
ViewModel + LiveData
) and it works really well! You can always use rxJava and access
Observables
in the presenter from
View
.