refactor(angular): unused subscription in routerlink (#24950)

This commit is contained in:
Sean Perkins
2022-03-19 13:10:21 -04:00
committed by GitHub
parent 0d0740161f
commit 63842a25c3

View File

@ -1,17 +1,14 @@
import { LocationStrategy } from '@angular/common'; import { LocationStrategy } from '@angular/common';
import { ElementRef, OnChanges, OnDestroy, OnInit, Directive, HostListener, Input, Optional } from '@angular/core'; import { ElementRef, OnChanges, OnInit, Directive, HostListener, Input, Optional } from '@angular/core';
import { Router, RouterLink } from '@angular/router'; import { Router, RouterLink } from '@angular/router';
import { AnimationBuilder, RouterDirection } from '@ionic/core'; import { AnimationBuilder, RouterDirection } from '@ionic/core';
import { Subscription } from 'rxjs';
import { NavController } from '../../providers/nav-controller'; import { NavController } from '../../providers/nav-controller';
@Directive({ @Directive({
selector: '[routerLink]', selector: '[routerLink]',
}) })
export class RouterLinkDelegateDirective implements OnInit, OnChanges, OnDestroy { export class RouterLinkDelegateDirective implements OnInit, OnChanges {
private subscription?: Subscription;
@Input() @Input()
routerDirection: RouterDirection = 'forward'; routerDirection: RouterDirection = 'forward';
@ -34,12 +31,6 @@ export class RouterLinkDelegateDirective implements OnInit, OnChanges, OnDestroy
this.updateTargetUrlAndHref(); this.updateTargetUrlAndHref();
} }
ngOnDestroy(): void {
if (this.subscription) {
this.subscription.unsubscribe();
}
}
private updateTargetUrlAndHref() { private updateTargetUrlAndHref() {
if (this.routerLink?.urlTree) { if (this.routerLink?.urlTree) {
const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree)); const href = this.locationStrategy.prepareExternalUrl(this.router.serializeUrl(this.routerLink.urlTree));