# tabsub

> A simple cross tab / window publish–subscribe mechanism.

Latest version **1.0.1** (published 2019-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tabsub
pnpm add tabsub
yarn add tabsub
bun add tabsub
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-10-19 |
| First published | 2019-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | vorillaz |

## Links

- npm: https://www.npmjs.com/package/tabsub
- npm.io page: https://npm.io/package/tabsub

## Recent versions

- 1.0.1 (latest) — 2019-10-19
- 1.0.0 — 2019-04-04

## README

<h1 align="center">Tabsub 📻</h1>
<p align="center">
  <strong>A tiny (~500B) Pub/Sub library that simply works</strong>
  <br/>
</p>

## Intro

Tabsub is a tiny library with minimal API that allows simple communication between browsing contexts with the same origin. It works with the BroadcastChannel API with a sensible fallback to localStorage, thus it works with all modern browsers.

## Installation

Install Tabsub from the NPM registry as:

```
npm install --save tabsub
```

## Usage

### Create a channel and send a message

```javascript
import tabsub from 'tabsub';

const radio = tabsub('channel-name');
radio.post('One message');
radio.post({msg: 'Another one'});
```

### Create a channel start listening for incoming messages

```javascript
import tabsub from 'tabsub';

const radio = tabsub('channel-name');
r.on(msg => {
  console.log(`Message received: ${msg} `);
});
```

### Pause and restart a channel

```javascript
import tabsub from 'tabsub';

const radio = tabsub('channel-name');
// Posting
radio.post('One message');
radio.stop();

radio.post('Ignored');

radio.start();
radio.post('Keep them coming');
```

## Browser support

All modern browsers using the [BroadcastChannel API](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) and the [localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)

---
_Source: https://npm.io/package/tabsub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
