@devhobby/tab-sync
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

tab-sync

Tab synchronizer is a library that allow you tu communicate between multiple tabs

compatibility

IE 9, Google Chrome, Mozilla Firefox, Safari, Opera and the most updated browser

install

npm i @devhobby/tab-sync --save

usage

first tab

import {TabSync} from '@devhobby/tab-sync'
const tabEmitter = TabSync()

setTimeout(() => {
	tabEmitter.sync('myEvent', { params: {<any>}, applyOriginEmitter: boolean })
}, 5000)

tabEmitter.on('myEvent', (data) => {
	console.log(data.params)
})

second tab

import {TabSync} from '@devhobby/tab-sync'
const tabEmitter = TabSync()

tabEmitter.on('hello', function (data) {
	console.log(data.params)
})

Note : tabEmitter.Sync() accept two parameters . The first param is the eventName to identify the event that will be emitted. The second param is a Object that contains two properties:

  1. params => arbitrary data that you would emit at all listeners

  2. applyOriginEmitter => this is a boolean that allow to emit also at emitterTab. default value is false.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.22latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.22
1.1.12
1.1.01
1.0.100
1.0.90
1.0.80
1.0.70
1.0.50
1.0.40
1.0.30
1.0.20

Package Sidebar

Install

npm i @devhobby/tab-sync

Weekly Downloads

5

Version

1.1.2

License

ISC

Unpacked Size

3.16 kB

Total Files

8

Last publish

Collaborators

  • varpdev
  • frabru