-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix($rootScope): allow destroying a root scope #10895
fix($rootScope): allow destroying a root scope #10895
Conversation
When running (i.e. bootstrapping and killing) multiple apps on the same page, it makes sense to destroy the root scope.
OMG!! A Pull Request from @vojtajina !! |
I thought that we had fixed this already... |
Looking through the history, it seems like we have just "never" detroyed the root scope and so that convention has followed on without question. I guess that in the past it was not expected that one would expect to kill an Angular app on a page. In that case, what is the deal with killing other singleton services like |
We never supported shutting down an angular app. There are several PRs that |
Another question, a specific use case would help understand the why of this |
@geddski wrote an angular layer called Overmind. Overmind affords two things to developers. First, it allows you to lazy-load pieces of your app. The second thing is affords you is an easy way to create multiple apps on the same page. Each app has it's own rootScope, meaning that the digest cycle for any given app doesn't affect the other apps on the page. This can improve performance. This is the use case. If you need more specifics, I can add them. |
Ok, but destroying the root scope will not stop the timed tasks nor release |
I guess that this isn't going to break anything and it seems that @vojtajina, @aaronfrost and probably @geddski feel it would benefit their use case. Unless there are any strong objections we should merge this PR this week. |
Looks very similar to #7564 which was closed without merging :) I think we should definitely merge this. I think DOM listeners are lower priority since I imagine that both in overmind and angular-widget the DOM is destroyed along with the micro-app. As you can see in https://github.com/wix/angular-widget/blob/master/app/scripts/services/widgets.js#L93-L96 it was also required for me to unset |
But @IgorMinar felt that #8005 was a more complete solution. This may be so, but I think we should be OK for now with this. What do you think @lgalfaso ? |
It is not only the listeners at the DOM, but everybody that called |
|
@lgalfaso - from looking at https://github.com/geddski/overmind/blob/master/src/overmind.js I think you are right that more would need to be done when killing a "sub" app than just removing listeners. I am thinking two things:
What do you think? |
Spot on Pete. That would be great. |
SGTM |
So, let's merge this and @geddski when you are not busy running a business and organising conferences might you like to look into a PR for the other stuff? |
@petebacondarwin really what is needed is the cleanup counterpart to #11015. Not sure what all needs to go into that, probably will depend on the lazy loading implementation. |
I just looked at merging this. It breaks a unit test but I think that it is not really testing the right thing anyway. I'll update and create a new PR. |
When running (i.e. bootstrapping and killing) multiple apps on the same page, it makes sense to destroy the root scope. Closes angular#11241 Closes angular#10895
When running (i.e. bootstrapping and killing) multiple apps on the same page,
it makes sense to destroy the root scope.
cc @aaronfrost
@IgorMinar @petebacondarwin What was the reason for ignoring
$destroy
on a root scope? Am I missing something here?