UNPKG

multi-tab-detection

Version:

Used to detect multiple tabs being opened

42 lines (41 loc) 1.61 kB
import { Subject } from 'rxjs'; export declare class MultiTabDetection { /** * @description Informs the listener that a new tab has been detected for the same browser session. * It also pass in the total number of tabs opened for the same browser session. */ NewTabDetectedEvent: Subject<number>; /** * @description Informs the listener that an existing tab existed for the same browser session. */ ExistingTabDetectedEvent: Subject<void>; /** * @description Informs the listener that a tab for the same browser session has been closed. * It also pass in the updated total number of tabs opened for the same browser session. */ ClosedTabDetectedEvent: Subject<number>; private prefix; private initiatedNewTabMessage; private numberOfTabsOpened; private newTabValue; constructor(); /** * @description Gets the total number of tabs opened. It is recommended to wait for 1 second * after receiving existingTabDetectedEvent before calling this property to get the accurate * total number of tabs opened. * @returns {number} */ readonly NumberOfTabsOpened: number; private addListener; private setNewTab; private readonly newTabKey; private readonly existingTabKey; private readonly closingTabKey; private incrementNumberOfTabsOpened; private decrementNumberOfTabsOpened; private setKey; private setLocalStorageKeyValue; private getLocalStorageValue; private createUniqueKey; private createUniqueValue; }