File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
packages/common/upgrade/src Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ export class $locationShim {
5959
6060 private urlChanges = new ReplaySubject < { newUrl : string ; newState : unknown } > ( 1 ) ;
6161
62+ private readonly removeOnUrlChangeFn : VoidFunction ;
63+
6264 constructor (
6365 $injector : any ,
6466 private location : Location ,
@@ -82,7 +84,7 @@ export class $locationShim {
8284 this . cacheState ( ) ;
8385 this . $$state = this . browserState ( ) ;
8486
85- this . location . onUrlChange ( ( newUrl , newState ) => {
87+ this . removeOnUrlChangeFn = this . location . onUrlChange ( ( newUrl , newState ) => {
8688 this . urlChanges . next ( { newUrl, newState} ) ;
8789 } ) ;
8890
@@ -249,6 +251,7 @@ export class $locationShim {
249251 } ) ;
250252
251253 $rootScope . $on ( '$destroy' , ( ) => {
254+ this . removeOnUrlChangeFn ( ) ;
252255 // Complete the subject to release all active observers when the root
253256 // scope is destroyed. Before this change, we subscribed to the `urlChanges`
254257 // subject, and the subscriber captured `this`, leading to a memory leak
You can’t perform that action at this time.
0 commit comments