Karthikkeyan Bala Sundaram
1 min readApr 23, 2019

--

I usually put the local-data-persistence or `DataManager` Layer along with the View Model Layer. View controller only communicates with the ViewModel, since it is a data backing layer, now it is the view model’s task to provide the view controller with the data. The data can come from either from local persistence or from network; this decision is made by view model.

I would write a logic in view model to first check the `DataManager` for any local data, if it is not available then make a network call using Service Layer and persist the data before return the data back to view controller.

Something like this,

Hope this helps.

--

--

No responses yet