I have F2 running in an SPA and have identified a race condition with a setTimeout on line 292 of container.js:
/**
* Instantiates each app from it's appConfig and stores that in a local private collection
* @method _createAppInstance
* @private
* @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
*/
var _createAppInstance = function(appConfig, appContent) {
// instantiate F2.UI
appConfig.ui = new F2.UI(appConfig);
// instantiate F2.App
if (F2.Apps[appConfig.appId] !== undefined) {
if (typeof F2.Apps[appConfig.appId] === 'function') {
// IE
setTimeout(function() {
_apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root);
if (_apps[appConfig.instanceId].app['init'] !== undefined) {
_apps[appConfig.instanceId].app.init();
}
}, 0);
}
else {
F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')');
}
}
};
The issue I'm having is when we destroy the app (when the user navigates away) before the 'async' code can execute. _apps[appConfig.instanceId] doesn't exist any more, but the setTimeout triggers anyway. I've created a gist with a patch in it.
Hey guys,
I have F2 running in an SPA and have identified a race condition with a setTimeout on line 292 of container.js:
The issue I'm having is when we destroy the app (when the user navigates away) before the 'async' code can execute. _apps[appConfig.instanceId] doesn't exist any more, but the setTimeout triggers anyway. I've created a gist with a patch in it.