The following code is from StartViewModel and is how I was lead to believe we should implement menu options:
Actions.Add(new ViewAction("Customers", execute: (a, o) => Controller.Action("Customer", "List"), category: "Customer")
Significance = ViewActionSignificance.AboveNormal,
ActionView = Controller.LoadView(StandardViews.LargeText03),
ActionViewModel = new CustomerListViewModel()
In this code, the last part creates a new instance of CustomerListViewModel.
The constructor in the CustomerListViewModel calls the LoadData() method - which for the list, brings down all the customers.
This is run before the menu options are displayed as it is part of how they get defined.
So when each xxxListViewModel gets defined, it gets a copy of all the data that should appear in the list - even though the call is only to define the menu, not display the data.
I would assume that the FW then does a refresh on the loaded data prior to displaying it when the menu option is selected.
My point is that, as the menu is being built, each ViewModel that is being attached to menu options is loading a bunch of data that is not needed at the time. If my app has well over a 100 tables, each with many rows, just getting the menu to show will be slow,
not to mention generating a ton of network traffic that isn't really used.
So my thought is that I want to instantiate the xxxListViewModel, but take the call to LoadData out of it. But if I do this, it doesn't work. So I need to know where I can move the LoadData call so that it is called before the view is rendered (but not on instantiation.)
I am guessing I can put it in an event, but not sure which one would be appropriate within the CODE FW, that's all.