Open stanbar opened 6 years ago
Hello,
there is a common problem in Android development :)
In Clean Architecture we does'n have a reference to View in ViewModel, so in my opinion we have to notify ViewModel from View about any text changes. Try to create some InputModel class that has all inputs state with error flag and expose LiveData
In this scenarion you always have actuall value stored in LiveData
This is only my proposed solution, please do not get it as the only right choice :)
Hello. The example here covers only fetching immutable data. But for me, the most challenging is creating and updating existing data. How to handle validation of mutable data, when there is high coupling between View and ViewModel. Should I keep track of each field separately ?
and then how to validate ?
And then observe on each error ?
I'm not sure of any of those lines And how to update
title
inViewModel
? ViaTextWatcher
? It becomes quite tricky, when it comes to updateTextView
fromViewModel
'sObservable
and updatingViewModel
fromTextView
'sTextWatcher
(recursive updates).An example of creating new and updating existing movies would be great 👍