@srounce/broadcastchannel

1.0.2 • Public • Published

tab-channel

send message to other tab in the same origin. use BroadcastChannel default, use storage event as fallback

Installation

npm i --save tab-channel

Usage

As a polyfill for BroadcastChannel:

import 'tab-channel/polyfill'

Use implementation directly:

import { BroadcastChannel as Channel } from 'tab-channel'

// channel name is required
var channel = new Channel('my-channel')

// get channel name
channel.name

// bind message event 
channel.onmessage = function(m) {
  // string msg in data property
  doAnything(m.data)
}

// send message
channel.postMessage('hello world')

// handle error message
channel.onmessageerror = function(e) {
  //e is an Error object
}

// close channel
channel.close()

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    3
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    3

Package Sidebar

Install

npm i @srounce/broadcastchannel

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

14.9 kB

Total Files

11

Last publish

Collaborators

  • srounce