lsbus

1.0.1 • Public • Published

The Local Storage Bus

This is a fork of lsbridge.

1K library for exchanging messages between tabs in a same browser. It uses the local storage as a communication channel.

The story behind the library is available here.

Usage

Add lsbus.min.js to your page:

<script src="js/lsbus.min.js"></script>

There is a global object lsbus available.

Send messages:

lsbus.send('my-namespace', { message: 'Hello world!' });

Listen for messages:

lsbus.subscribe('my-namespace', function(data) {
  console.log(data); // prints: { message: 'Hello world!'}
});

Find out if localStorage is available:

console.log(lsbus.isLSAvailable); // prints "true" or "false"

Compilation

  • Run npm install to get UglifyJS installed.
  • Run npm run-script compile to produce build/lsbus.min.js

Example

Try it yourself by opening example/index.html in a browser.

lsbridge

Package Sidebar

Install

npm i lsbus

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • grayfox