I am trying to implement MVVM structure in my new app. I have the following layers.
My viewcontroller does its job perfectly fine that is rendering ui and updating views and viewmodels for the changes.
Now when I need to call an api. ViewController asks Viewmodel to fetch data. It asks Manager(repository) to fetch the data. Manager calls NetworkManager(common for full app) to call the api and get data.
Manager also creates urlrequest with body and queryparams. Manager gets the APIModel which it converts to Cachodel and gives to CacheManager to write.
My Manager gives API model back to viewmodel and based on its requirements, viewmodel converts apimodel to business using a Transformer layer.
Now I am confused between whether to give apimodel to viewmodel or convert it to businessmodel at manager layer and give businessmodel to viewmodel.
What is the best way to achieve this or if I am already doing something wrong in the architecture.
Not sure 100% your problem, but to me, my controller onlys know ViewModel. ViewModel will call Manager (Repository) to do any stuff (logic, network, etc) then let controller know to refresh, update, render UI... That way, i can follow The Single Responsibility Principle.