browser-tabs-event
v0.1.10
Published
You can subcribe windows tab event when it closed, the first time app loaded, the first time tab loaded, or when all all tabs was closed
Downloads
14
Maintainers
Readme
Detect Browser's Tab Events
You can subscribe window tabs event with following support functions:
handleOnFirstTimeLoadApp
- All tab was closed (or the first time load application in current browser)
- If you close all tabs, then access again, it's mean you are access at the first time
- All tab was closed (or the first time load application in current browser)
handleOnFirstTimeLoadTab
- First time load tab
handleOnUnMountTab
- Handle on a tab is closing
TS way
import { BrowserTabsEvent } from 'browser-tabs-event'
const App: FC = (): JSX.Element => {
// first time load app
const handleOnFirstTimeLoadApp: any = (
tabId: string,
isFirstTimeLoadApp: boolean
): void => {}
// first time load tab
const handleOnFirstTimeLoadTab: any = (
tabId: string,
isFirstTimeLoadTab: boolean
): void => {}
// handle on unmount tab
const handleOnUnMountTab = (tabId: string): void => {}
// ...
return (
<BrowserTabsEvent
handleOnFirstTimeLoadApp={handleOnFirstTimeLoadApp}
handleOnFirstTimeLoadTab={handleOnFirstTimeLoadTab}
handleOnUnMountTab={handleOnUnMountTab}
/>
)
}
JS way
import { BrowserTabsEvent } from 'browser-tabs-event'
const App = () => {
// first time load app
const handleOnFirstTimeLoadApp = (tabId, isFirstTimeLoadApp) => {}
// first time load tab
const handleOnFirstTimeLoadTab = (tabId, isFirstTimeLoadTab) => {}
// handle on unmount tab
const handleOnUnMountTab = tabId => {}
// ...
return (
<BrowserTabsEvent
handleOnFirstTimeLoadApp={handleOnFirstTimeLoadApp}
handleOnFirstTimeLoadTab={handleOnFirstTimeLoadTab}
handleOnUnMountTab={handleOnUnMountTab}
/>
)
}
Setting
npm i -s browser-tabs-event