Within Exrin, using the normal hierarchy of ViewModel having access to the IModel, The Model having access to the IService, and Operations commonly having access to the IModel yet being called from the ViewModel, what is the proper use of methods and interactions within each scope?
For example, I need to clear a table in my SQLite database on navigating to a page. I have an IRepositoryService that contains all my methods for interacting with our database. My Model has a ClearUserInputTables method that calls a few different methods within the IRepositoryService.
I could either override the OnAppearing method (may likely change it to a different point in the life cycle) within the ViewModel to call the Model.ClearUserInputTables method or I could create an Operation that has access to the Model to do the same thing. Which is favored in Exrin?
Maybe I need a better understanding of the purpose of Operations. I read up on Operation Separation (basically used for navigation), but am unsure if it should be used for other things such as this (calling Model methods from the ViewModel).
Operation's are designed to take code outside of the ViewModel, so it can
Operation's however are completely optional. You don't have to use them.
If you want to clear a table when you navigate to a page, I could recommend
This is only called once when the page first loads.
Is called when the back is navigated to, via the page in front of it being popped. But
Is called every time you see the page, regardless of how you got there. However if that's what you want, then it can be used for clearing your database tables.
Because an Operation is essentially part of the ViewModel, you can think of them at the same level as an operation. Hence
You just pass the model through, via the Operation constructor.
As a side note, I realize that Operations can be a lot of overhead. They are optional. If you don't really need the benefits, listed at the start of this answer, then you can just call the Model directly from OnAppearing, without using an Operation.