A widget may have both private settings and category settings, and it is entirely up to you how you combine them. A typical - but absolutely not compulsory - path of execution would be:
If
If
Otherwise, use defaults
Note: if your settings involve a selection of market or timeframe, you may want to include an extra step: respecting context from the MyTrader page container.
The only extra consideration then is that, even if there are private settings, you may still want to call
For example, using FXB.utils.IsEmpty() as a helper to check for empty objects:
Framework.OnLoad = function() {
// Start with a null value
Framework.$myState = null;
// If private settings exist, set the record of the state
if (!FXB.utils.IsEmpty(Framework.privateSettings)) {
Framework.$myState = Framework.privateSettings;
}
// Always do a LoadCategorySettings(), even if we have private settings
Framework.LoadCategorySettings("my-widget", function(categorySettings) {
if (Framework.$myState) {
// If we already have private settings, ignore the category settings
} else {
// Put the category settings - which may be empty - into the state
Framework.$myState = categorySettings;
}
// If myState is still empty, because we have neither private nor category
// settings, then use some defaults
if (FXB.utils.IsEmpty(Framework.$myState)) {
Framework.$myState = { … some defaults … };
}
// And, finally, do UI initialisation based on the settings or defaults
Framework.$UpdateMyUI();
});
};