Vue>> cwb>> 返回
项目作者: mvasilkov

项目描述 :
Cross-Window Broadcasting and Locking
高级语言: JavaScript
项目地址: git://github.com/mvasilkov/cwb.git
创建时间: 2019-04-11T14:01:49Z
项目社区:https://github.com/mvasilkov/cwb

开源协议:MIT License

下载


cwb: Cross-Window Broadcasting

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

npm
dependencies


Installation

  1. npm add cwb

Usage

Communicating between tabs

Subscribe to events

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

Publish events

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

Send to the same tab

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

Locking (synchronization)

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

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