I have a Javascript Object made this way:
function App(callback){
// Call some "long running functions meant for initialization
callback(this);
}
In my main Template page (_Layout.cshtml on ASP MVC) I instanciate it like this:
_Layout.cshtml
var oApp = new App(function(initializedApp){
// Instanciate here other Javascript components that depend on
// App initialization
var oComponent1 = new Component1(initializedApp);
});
This works fine ! Component1 is initialized afte App has finished initializeing and all goes fine.
Proble rises in Page1.cshtml (which is rendered inside _Layout.cshtml and have access to oApp). Page1 also has to initialize its own component that need App to be fully initialized.
Page1.cshtml
// How do I "subscribe to the App callback function so that Compnent2, s
// specific to the Page1.cstml, is initialized afetr App has finished
// its initialization ???
var oComponent2 = new Compnent2(oApp);
oApp.callback(); // ???
oApp(function(initializedApp){ // code here... }); //???
Thanks
Lorenzo