From 704679f5bbe590a7b51dcd91cf7837c39caf96fb Mon Sep 17 00:00:00 2001 From: Michel Selerin Date: Sat, 6 Feb 2021 23:04:38 +0100 Subject: [PATCH] fix: use `take(1)` inside `handleStateChange` instead of `unsubscribe()` --- .../ngx-security/src/lib/directives/ngx-security.directive.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/ngx-security/src/lib/directives/ngx-security.directive.ts b/projects/ngx-security/src/lib/directives/ngx-security.directive.ts index 49ae0e4..709b40c 100644 --- a/projects/ngx-security/src/lib/directives/ngx-security.directive.ts +++ b/projects/ngx-security/src/lib/directives/ngx-security.directive.ts @@ -40,6 +40,7 @@ export class BaseSecurityDirective implements OnInit, OnDestroy { protected handleStateChange(): void { this.isAuthorized().pipe( + take(1), map(hasPerm => { if (this.lastValue !== hasPerm) { this.lastValue = hasPerm; @@ -52,7 +53,7 @@ export class BaseSecurityDirective implements OnInit, OnDestroy { this.viewContainer.createEmbeddedView(this.elseTemplateRef); } }) - ).subscribe().unsubscribe(); + ).subscribe(); } /* istanbul ignore next */