Hi all,
I'm currently trying to solve some issues I'm having with Apache Royale, which uses closure underneath and the issue I tracked down is in the closure part of the library, so I'm asking here. Currently working on the debug output ... release will be the next on my list ;-)
So I have an application which uses some framework types. This application loads multiple modules. These share some types used by the main application, share some with other modules and use some of their own types.
The first als the last are not the problem. It however starts to get tricky if I load two modules at the same time (or at least almost at the same time). From what I see here is that the first module that gets returned starts listing dependencies and their locations. Then the module is initialized by calling goog.require ... the type is not loaded yet, so the library checks the dependency list and adds this to the missing resources list ... same with any of the dependencies of this type. So in the end it's a pretty long list of stuff to get from the server. So the library fetches this and the next module starts doing the same.
Unfortunately the requested resources haven't been returned from the server yet and therefore they didn't have the chance to register themselves. So the second module potentially requests some resources again. As the url of the resources of the second module differs, the browser also tries to fetch them.
Now as soon as the first set of resources come back, they register themselves and all is good. But as soon as the second batch comes, they try to re-register, which causes errors.
My question now is: how can I avoid this problem? I was thinking of also maintaining a list of requested types so if it's not registered yet but it has already been requested, to simply start waiting for the other request to return.
I created an issue in the Royale project which has some more information:
Would greatly appreciate any suggestions ... queueing the modules to start loading the next one as soon as the first is done doesn't seem to be an ideal solution.
Thanks,
Chris