Model–View–ViewModel (MVVM)


#1

Hello!

Ask ko lang if strict ba sa MVVM na dapat iba’t ibang ViewModel sa bawat ViewController?
Or pede gamitin yung viewModel sa first ViewController pa punta sa second ViewController?

Thanks!


#2

Yes and di lang 1 VM sa isang VC, it can be more than that sa isang VC. If you have many subviews, it is possible each view component will have its own VM. Any data for display must be wrapped in a VM. VM allows us to separate the displayed data from the data used by the biz processes. As long as you keep in mind that you separate display(VM) object from object processed you’ll know what to do.