I want to show session timeout popup for every 10 min . I am putting an issued time in session storage in a service file and also from same file I am starting the timer. The reason I am doing this is that in every response I get a new issued time . So I am passing issued time from session storage to a popup. The problem I am getting here is I cannot call a component from that particular service, the reason is "Circular dependency in service -> component -> service -> component"
This is my service file
@Injectable({
providedIn: 'root'
})
export class HttpBaseService {
constructor(public authHttp: HttpClient, private modal: MatDialog,
private toastr: ToastrManager) { }
public handleAPIResponse(response: any) {
if (response.accessToken) {
const tokenInfo =
this.getDecodedAccessToken(response.accessToken);
const issuedTime = tokenInfo.exp;
this.setToken(response.accessToken, issuedTime);
//Here I am starting the timer with latest issued time.
this.startTimer(issuedTime);
}
return response.result;
}
}
startTimer(issuedTime: number) {
///login to calculate time
//call a modal popup here if time is up.
this.modal.open(ModalPopupComponent, {
}
}
This is my ModalPopupComponent
@Component({
selector: 'app-modal-popup',
templateUrl: './modal-popup.component.html',
styleUrls: ['./modal-popup.component.scss'],
})
export class ModalPopupComponent implements OnInit {
//logic to show countdown of One min to logout automatically
}
Need to know how can I call modal component from this service, without any circular dependency. Thanks in Advance