-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
unmount() reloads browser while trying to get $uiRouter instance #59
Comments
I looked into this a little bit though I'm not as familiar with Angularjs. I believe this is due to using that old of a version of ui-router. |
I will try to upgrade to rc-1 then, thanks for the tip @filoxo, but either way, if someone has the microfrontend set up like this: singleSpaAngularJS({
angular,
mainAngularModule: app,
uiRouter: false,
...
}); shouldn't have to be there a conditional like this? if (opts.uiRouter) {
var uiRouter = mountedInstances.instance.get("$uiRouter");
if (uiRouter) {
uiRouter.dispose();
}
} |
Hmm possibly? The docs are unclear on what .get would return if that module has not been instantiated before (a new instance? or something falsy if there are no previously created instances?), and I'm still very rusty. But I still did a little digging and found the source and it does appear to try to instantiate if the module if not already: Can you confirm that that's the case? Perhaps if (mountedInstances.instance.has("$uiRouter")) {
var uiRouter = mountedInstances.instance.get("$uiRouter");
uiRouter.dispose()
} I'm also thinking that this could be improved by checking that the router module has a if (mountedInstances.instance.has("$uiRouter")) {
var uiRouter = mountedInstances.instance.get("$uiRouter");
if(!uiRouter.dispose) {
console.warn('The uiRouter instance does not have a dispose method and so it cannot be cleaned up.')
} else {
uiRouter.dispose();
}
} What do you think? |
@filoxo I think your proposal above is good. Do you have interest in sending in a PR with the fix? If not, I may have time to do so. |
I won't get to this so feel free to implement it. |
Hi,
our project is using ui-router@1.0.0-beta.1 and seems like since is not a final 1.0.0 release, it does not have a provider for '$uiRouter' nor a
dispose()
method.I believe because of that, when the
unmount()
lifecycle function executes the following:my microfrontend breaks throwing this error:
and then the browser gets reloaded.
I've looked at that source code of ui-router@1.0.0-beta.1 and it seems like '$uiRouter' is provided as 'ng1UIRouter', so if I patch the
unmount()
method to:it finds the instance but it still breaks since it does not have the
dispose()
method.I'm not sure what's the
dispose()
equivalent method of 'ng1UIRouter', if exists, or what's it for, but if I simply remove all those lines it works perfect for me, I don't see any sign of #53 which is the issue that those lines are meant to fix.Wrapping up, I wonder if it'd be desired to have a flag to toggle that feature, I know that I'm using a beta version of ui-router and should consider upgrading it, we've tried but got a lot of issues making us to give up. Anyways, I don't see a conditional either, which should check if
opts.uiRouter
is truthy, based on that I believe this issue may happen as well if your app doesn't have uiRouter at all.The text was updated successfully, but these errors were encountered: