How can I observe changes to Variable<...>
value (RxSwift
Variable
) inside the ViewModel
class from the ViewController
?
So in case the value of any of my Variable<..>
that I have in the ViewModel
changes within the things happening in the ViewModel
then the ViewController
will be noticed "Hey! One or more Variable<..> in the ViewModel changed! Ask the ViewModel for the data you need to update the UI and update the UI!"
And then the ViewController
call a method updateUI()
inside the ViewController and within it it asks the ViewModel
for all the info like status/state to update the UI something like:
func updateUI() {
progressBar.hide = viewModel.getProgressBarVisibility()
errorMessageLabel.hide = viewModel.getErrorMessageVisibility()
errorMessageLabel.text = viewModel.getErrorMessageText()
.....
...
}