nebular
nebular copied to clipboard
Memory leak of accessChecker.isGranted ??
Version 9
I'm using this to display a button depending on user roles :
<button *ngIf="(accessChecker.isGranted('edit', 'mep') | async)" class="multiple-action-button" nbButton status="info" type="button" (click)="editComponentOfMep(element)" title="Edition du composant de la MEP" size="small"><i class="fas fa-edit fa-lg"></i></button>
It is calling this method :
@Injectable()
export class NbSimpleRoleProvider extends NbRoleProvider {
getRole(): Observable<string> {
return this.authService.onTokenChange()
.pipe(
map((token: NbAuthJWTToken) => {
console.log('Ton role est : ' + token.getPayload().roles[0].authority); // Calling so much time this !
return token.isValid() ? token.getPayload().roles[0].authority : 'GUEST';
}),
);
}
..
..
..
}
The problem is that the page is calling so many times "accessChecker.isGranted" ! For each row of my table it calls the accessChecker, and if i keep the mouse on the button without doing anything else, it keep calling "accessChecker.isGranted" !
So thousand of calls in few seconds..
