cwb
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

cwb: Cross-Window Broadcasting

cwb (pronounced wub) is a JavaScript library for cross-window broadcasting and locking.

npm dependencies


Installation

npm add cwb

Usage

Communicating between tabs

Subscribe to events

import { Channel } from 'cwb'
 
const chan = new Channel('foo')
chan.on('bar', b => console.log('Got bar:', b))

Publish events

/* In another tab */
 
const chan = new Channel('foo')
chan.send('bar', 'Porter and Sons')

Send to the same tab

chan.send('bar', 'Porter and Sons', { toSelf: true })

Locking (synchronization)

import { lock } from 'cwb'
 
lock('foo', () => {
    /* Critical section. This function can be async. */
})

Changelog

1.0.0

Migrate to TypeScript

0.0.3

New method: Channel#dispose

0.0.2

New method: Channel#update

License

MIT

The ObjectId type (a vendored dependency) comes from bson, which is licensed under the Apache License 2.0

Package Sidebar

Install

npm i cwb

Weekly Downloads

9

Version

1.0.0

License

MIT

Unpacked Size

68.5 kB

Total Files

11

Last publish

Collaborators

  • mvasilkov