Skip to content

Commit

Permalink
fix(upgrade): Use takeUntil on leaky subscription. (#50901)
Browse files Browse the repository at this point in the history
Using the life cycling hook `onDestroy` to end the subscription.

fixes #48032

PR Close #50901
  • Loading branch information
JeanMeche authored and dylhunn committed Jul 11, 2023
1 parent 8bb6b7d commit 253d756
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ApplicationRef, ChangeDetectorRef, ComponentFactory, ComponentRef, EventEmitter, Injector, OnChanges, SimpleChange, SimpleChanges, StaticProvider, Testability, TestabilityRegistry, Type} from '@angular/core';
import {ApplicationRef, ChangeDetectorRef, ComponentFactory, ComponentRef, EventEmitter, Injector, OnChanges, SimpleChange, SimpleChanges, StaticProvider, Testability, TestabilityRegistry} from '@angular/core';

import {IAttributes, IAugmentedJQuery, ICompileService, INgModelController, IParseService, IScope} from './angular1';
import {PropertyBinding} from './component_info';
Expand Down Expand Up @@ -211,10 +211,11 @@ export class DowngradeComponentAdapter {
}
const emitter = componentRef.instance[output.prop] as EventEmitter<any>;
if (emitter) {
emitter.subscribe({
const subscription = emitter.subscribe({
next: isAssignment ? (v: any) => setter!(this.scope, v) :
(v: any) => getter(this.scope, {'$event': v})
});
componentRef.onDestroy(() => subscription.unsubscribe());
} else {
throw new Error(`Missing emitter '${output.prop}' on component '${
getTypeName(this.componentFactory.componentType)}'!`);
Expand Down

0 comments on commit 253d756

Please sign in to comment.