1.0.10 • Published 5 years ago

@devhobby/tab-sync v1.0.10

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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 '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 '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.

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago