# domain-bus

> Cross-window communication in the browser

Latest version **0.0.2** (published 2016-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install domain-bus
pnpm add domain-bus
yarn add domain-bus
bun add domain-bus
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-05-16 |
| First published | 2016-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Thomas Jensen |
| Maintainers | thomas-jensen |

## Links

- npm: https://www.npmjs.com/package/domain-bus
- Repository: https://github.com/srcagency/domain-bus
- Homepage: https://github.com/srcagency/domain-bus#readme
- Issues: https://github.com/srcagency/domain-bus/issues
- npm.io page: https://npm.io/package/domain-bus

## Recent versions

- 0.0.2 (latest) — 2016-05-16

## README

# Domain bus

Seamless communication between browser tabs/windows on the same domain.

- Works offline
- Uses `localStorage` to synchronize
- Inspired by [page-bus](https://www.npmjs.com/package/page-bus)
- See also [browser-bus](https://github.com/srcagency/browser-bus)

## Examples

```js
var Bus = require('domain-bus');

var bus = new Bus();

bus.listen(function( message ){
	if (message === 'ping')
		bus.write('pong');

	console.log(message);
});

bus.write('ping');
```

Run the above script in a minimum of two tabs simultaneously.

Open `example.html` in multiple tabs to see a very basic chat functionality.

## Interface

```js
var bus = new Bus({
	// defaults
	env: window,
	namespace: '',
});

// write a message to the bus. Any JSON value is supported via JSON.stringify.
bus.write(message);

bus.listen(fn); // `fn(message)` will be called for each received message
```

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