Skip to content

Commit

Permalink
fix: don't reload a dependency that was just loaded
Browse files Browse the repository at this point in the history
Fixes #64
  • Loading branch information
ocombe committed Sep 10, 2014
1 parent 6838c34 commit 6752bb9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ocLazyLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var regModules = ['ng'],
regInvokes = [],
regConfigs = [],
justLoaded = [],
ocLazyLoad = angular.module('oc.lazyLoad', ['ng']),
broadcast = angular.noop;

Expand Down Expand Up @@ -457,6 +458,7 @@
moduleCache.push(moduleName);
loadDependencies(moduleName).then(function success() {
try {
justLoaded = [];
register(providers, moduleCache, params);
} catch(e) {
$log.error(e.message);
Expand Down Expand Up @@ -704,7 +706,7 @@
if(typeof moduleName !== 'string') {
moduleName = getModuleName(moduleName);
}
if(!moduleName) {
if(!moduleName || justLoaded.indexOf(moduleName) !== -1) {
continue;
}
moduleFn = angular.module(moduleName);
Expand All @@ -717,6 +719,7 @@
invokeQueue(providers, moduleFn._configBlocks, moduleName, params.reconfig); // angular 1.3+
broadcast('ocLazyLoad.moduleLoaded', moduleName);
registerModules.pop();
justLoaded.push(moduleName);
}
var instanceInjector = providers.getInstanceInjector();
angular.forEach(runBlocks, function(fn) {
Expand Down

0 comments on commit 6752bb9

Please sign in to comment.