You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
814 B

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
export const IMPERSONATION_KEY = 'impersonationId';
@Injectable({
providedIn: 'root'
})
export class ImpersonationStorageService {
private hasImpersonationChangeSubject = new BehaviorSubject<string>(
this.getId()
);
public constructor() {}
public getId(): string {
return window.localStorage.getItem(IMPERSONATION_KEY);
}
public onChangeHasImpersonation() {
return this.hasImpersonationChangeSubject.asObservable();
}
public removeId() {
window.localStorage.removeItem(IMPERSONATION_KEY);
this.hasImpersonationChangeSubject.next(null);
}
public setId(aId: string) {
window.localStorage.setItem(IMPERSONATION_KEY, aId);
this.hasImpersonationChangeSubject.next(aId);
}
}