I am building an app that can track weight. I allow the user to select their unit preference of kg or lbs. I want to keep the data in the DB standard (kg) so if the user selects lbs as their preference I need the data converted from kg to lbs in the UI.
Share
This conversion can be handled very easily in the ViewModel.
This is one of the huge advantages of having a ViewModel – you can have easily testable logic, such as conversion between units, which stays completely separate from the user interface code.