I have the following observable:
this.roles$ = auth.User$
.pipe(tap((val: JwtUser|null) => this.logger.debug('Session updated, updating permissions %o', val)))
.pipe(switchMap(this.getRoles.bind(this)))
.pipe(shareReplay({refCount: true, bufferSize: 1}));
The getRoles() method performs a HTTP request every time the User$ emits. The last fetched value is replayed to all new subscriptions. When the User$ emits, however, I do not want subscriptions to get the last value. Instead, I want them to wait for the newly fetched one. I thought I could achieve this by resetting/clearing the buffer whenever User$ emits, but I can't figure out how to do this. Is there an other approach I could try or a way to achieve this one?
Thanks!