Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Lazy loading with reconfig: true edge cases #54

Closed
charandas opened this issue Aug 18, 2014 · 7 comments
Closed

Lazy loading with reconfig: true edge cases #54

charandas opened this issue Aug 18, 2014 · 7 comments
Labels

Comments

@charandas
Copy link

I have had fair success using ocLazyLoad with ui-router-extras futureStates to lazy load requirejs-bases angular modules that define ui-router states. Huh! that line included some 4 packages.

I have had to use the reconfig: true so far. Now, I am trying to create a demo app and for some reason, I can never get the config block of the second lazy loaded module to run.

Run with the example and the first lazy loaded module (choose apple, or orange) works.
Example
Source code
ocLazyLoad code

Breakpointing in js/states/apple.js and js/states/orange.js, you will find that whichever one is clicked first gets its config block run properly, while the second lazy loaded module would not.

Any further insights as to what might be happening?

@ocombe
Copy link
Owner

ocombe commented Aug 19, 2014

Thanks for the very detailed issue, I will look into it but not until next week. In the mean time, could you try the code from this PR: #44 which you should be able to find here: https://github.com/BenBlazely/ocLazyLoad/blob/master/src/ocLazyLoad.js ?
I have to find the time to test it before I accept the PR (next week...) but maybe it will solve your problem too ? (not sure if it's related)

@charandas
Copy link
Author

@ocombe thanks for the suggestion. This particular PR doesn't fix my issue. Would look forward to your feedback next week. Until then, take it easy.

@chrisknu
Copy link

Chiming in here, as I'm running into the same issue. It appears to be the case that if reconfig is called at any point in an element passed into invokeQueue (prior to the resolution of all promises), the loop at 664 dies. Need to read over the rest of the source for a clearer picture, but if anything, I hope this helps

@charandas
Copy link
Author

@ocombe any more progress on this. This is non-critical for me, as it was just about writing a blog post on combining the power of ocLazyLoad with ui-router-extras. But nevertheless, a closure would be nice :)

Interestingly, I haven't yet run into this in production - if that happens, I would have to resort to eager loading.

@ocombe
Copy link
Owner

ocombe commented Aug 25, 2014

I started working on this yes, should know more tomorow (I spent most of the day catching up on emails & news)

@ocombe ocombe added the bug label Aug 26, 2014
@ocombe ocombe closed this as completed in 361ae6b Aug 26, 2014
@ocombe
Copy link
Owner

ocombe commented Aug 26, 2014

Ok it's fixed ! There was a case where reconfig would not work as expected :)
Can I use your github repo as a new example ? It's a nice complex example yet simple to understand

@charandas
Copy link
Author

Terrific! 👍 it worked. Thanks.

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

No branches or pull requests

3 participants