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

AngularJS: Broken lazy loaded modules on state removal #422

Open
realph opened this issue May 9, 2018 · 1 comment
Open

AngularJS: Broken lazy loaded modules on state removal #422

realph opened this issue May 9, 2018 · 1 comment

Comments

@realph
Copy link

realph commented May 9, 2018

I'm using ocLazyLoad in combination with UI-Router to lazy load my modules on state transition.

const state = {
  name: 'home.**',
  url: '/home',
  lazyLoad = transition => {
    transition
      .injector()
      .get('$ocLazyLoad')
      .inject('home-module.ts');
  };
}

$stateRegistry.register(state);

This works great. I'm able to visit that state which lazy loads home-module.ts, which in turn registers the components that are a part of home-module.ts. This all works as expected.

I then want the ability to de-register that very state, and reregister the same state.

$stateRegistry.deregister(state);
$stateRegistry.register(state);

If I now revisit the home.** state the module is not lazy loaded and its components aren't registered. I'm trying to understand what's going on here.

I have a feeling that when we deregister the state, something happens to that lazy loaded module - it's not unloaded because we cannot do that in JS. I'm guessing that the namespace (the module name) creates a pointer that references the original state name (home.**) and when we deregister the state, that pointer is broken. I'm out of ideas at this point.

Any help on this would be appreciated. Thanks in advance!

@vort3xxx
Copy link

If you don't mind me asking, what's the use case for deregistering a state at runtime? That's something I've never actually seen done in the wild and I'd like to know more.

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

No branches or pull requests

2 participants