Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Brodcast module load event invoke multiple time. #64

Closed
hlege opened this issue Sep 10, 2014 · 5 comments
Closed

Brodcast module load event invoke multiple time. #64

hlege opened this issue Sep 10, 2014 · 5 comments

Comments

@hlege
Copy link

hlege commented Sep 10, 2014

Hi!

In "register" function get called with registerModules and didn't check the module is loaded or not.

e.g.:
angular.module("foo" , ["bar","bar2"]);

When it resolved the bar and bar2 is brodcasted , but when it resolve foo it call register function again
and broadcast bar and bar2 again.

I made a hot fix in line 680 with the following check:
if(regModules.indexOf(moduleName) !== -1) {
registerModules.pop();
continue;
}

@ocombe
Copy link
Owner

ocombe commented Sep 10, 2014

Hi, could you do me a plunkr with the bug in question so that I can check if your hotfix is the right solution ?

@hlege
Copy link
Author

hlege commented Sep 10, 2014

http://plnkr.co/edit/HjbEEigCaLrdqgR4JpZ6?p=preview
change the oclazyload_bug.js to oclazyload.js to see the fix.

Note: in the source code lot of ";" missed at the end of function.

@ocombe
Copy link
Owner

ocombe commented Sep 10, 2014

Thanks, I'll take a look at it this afternoon

@ocombe
Copy link
Owner

ocombe commented Sep 10, 2014

Ok I found the problem, we add the required modules foo, bar & bar2 to the "to-load" modules list, but then for each module we add also load the dependencies.
We will load in reverse order bar2 (no dependency), bar (no dependency), foo: 2 dependencies bar & bar2 that we will load again.
I need to make sure that we don't load those multiple times in the same loading batch.

The fix is a bit more complicated than your hot fix because we need to take into account that sometimes people want to reload the config/run functions of those modules.

I think that I know how to fix it but I have to make more test to be sure that I don't break anything. Anyway, thanks for the report ! I'll let you know once it's fixed.

@ocombe ocombe closed this as completed in 6752bb9 Sep 10, 2014
@ocombe
Copy link
Owner

ocombe commented Sep 10, 2014

It's fixed in 0.3.7 !

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants