I need to create an inactivity modal in my Angular project using timer from RxJS. Since I'm new with RxJS, I'm having a troubles with it. Here is the code I have right now. It works but the issue that I have is to restart the timer after the user clicks. At this point, I can cancel the timer with takeUntil condition, but I can restart again the timer. I have been researching examples and code but all of them works with click events of Start, Stop, Restart buttons, and I need the events occurs after the takeUntil execution. Thanks for any help anybody could give me!
fromEvent(document, 'scroll');
this.authManager = new BehaviorSubject(AuthState.INITIAL_STATE);
this.authChange = this.authManager.asObservable();
this.authChange.pipe(
filter((authState: AuthState) => authState === AuthState.LOGGED_IN),
map((authState:AuthState) => timer(8000).pipe(
takeUntil(clickEvent)
)),
tap(() => console.log('logged in. session timeout counting down from now'))
).switch().subscribe(() => {
console.log('timer ended: logging out');
this.waitingUserResponse();
});