akveo / akveo/nebular

Memory leak of accessChecker.isGranted ??

Open
#3,027 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.1k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Version 9

I'm using this to display a button depending on user roles :
```

```

It is calling this method :

```
@Injectable()
export class NbSimpleRoleProvider extends NbRoleProvider {

getRole(): Observable {
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..
![memory_leak](https://user-images.githubusercontent.com/30440458/153761798-921dd809-4c9a-481e-8bcb-8bec287aff5d.gif)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.