ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

add config param 'renew' #265

Closed mikhail-angelov closed 8 years ago

mikhail-angelov commented 8 years ago

Hi Sometime It's needed to reload dynamic modules and initialize them properly there are 2 useful params for it: rerun, reconfig It will be nice to add one more (e.g. renew), which force to register module components

BR Mikhail

ocombe commented 8 years ago

Hmm are you sure that it works ? Don't you think that it could have disastrous effect if you reset components that have might be used by the application ?

mikhail-angelov commented 8 years ago

it's working at least in my case: I'm making application, which load modules dynamically depend on login user I do not like reset browser page on logout, so I reset angular contact (remove dom element connected with angular) and compose new angular content again.

here I faced with problem, since ocLazyLoad is not reloaded it keeps state, even if all angular app content is gone, and I did not find a way how to reset ocLazyLoad and make it properly init dynamic modules (it thinks all services and controllers already loaded, and does not register them any more) since you already have similar params (reconfig, rerun) which help to solve similar issue, I thought one more will be ok

I agree it may cause unexpected behavior if application content was not reset so it should be used responsibly :)

ocombe commented 8 years ago

Then maybe we should offer a way to reset the internal arrays of ocLazyLoad instead ?

mikhail-angelov commented 8 years ago

yes, it will work as well. we need just clean regInvokes map I can prepare such solution

ocombe commented 8 years ago

Yeah, that would be better, and we could use it in the unit tests as well

mikhail-angelov commented 8 years ago

pull request is updated, but I'm not sure the solution is better than previous one I did not manage to make unit test for it, because this function update internal state, which is not visible via API (

ocombe commented 8 years ago

I copied your code and rewrote the commit because you were bumping the version in your commit. Thanks for the PR, it's available on master.

mikhail-angelov commented 8 years ago

ok, thank you