Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

only-one-tab

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

only-one-tab

Run a function in exactly one open tab, switching to another if closed

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Only One Tab

Greenkeeper badge Travis badge standard badge npm

Run a function in exactly one open tab, switching to another if closed.

Goals

  • Robust across browsers
  • Fully tested

Usage

const onlyOneTab = require('only-one-tab')

// only one daemon will run at a time across all tabs
onlyOneTab(() => {
  startDaemon()
})

API

onlyOneTab(cb)

The callback is run only once per tab, and on exactly one tab at a time. When the actor tab that ran the callback is closed, then exactly one other open tab runs its callback to replace it as the actor.

Recovery

After a browser crash, or something similar, the actor tab can be closed without being replaced normally.

Every tab periodically checks for an active tab's heartbeat, and after 1-4 seconds, a new tab will become the actor to replace the crashed tab. A refresh or new tab will do the check immediately on startup as well.

If nothing goes wrong, a new actor replaces the closed tab immediately.

Keywords

FAQs

Package last updated on 28 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc