2.1.11 • Published 5 years ago

tabs-broadcast v2.1.11

Weekly downloads
2
License
GPL
Repository
github
Last release
5 years ago

Tabs broadcast system.

This package allows you to communicate arbitrary data between browser tabs, as well as transfer events between them. This solution is supported in Chrome, Firefox and Opera. The exact version support can be found in caniuse.com

Install

Using npm

npm install tabs-broadcast

Using yarn

yarn add tabs-broadcast

Use plugin (ES6)

Return the class that you want to initialize

import TabsBroadcast from 'tabs-broadcast'

Methods

.$emit( message: {String}, data: {String} ) - sends any event with arbitrary data to the browser .$on( message: {String}, callback: {Function} ) - listens for events within the browser .$once( message: {String}, callback: {Function} ) - listens for events within the browser. Deletes the subscription to the event after a call to callback .$off( message: {String} ) - unsubscribes from wiretapping events of the specified method

Example

// Written in a file that handles authorization 
TabsBroadcast.$emit('USER-IS-AUTH', { userData: {username: 'Ravy'}})

// It is written in the file that causes authorization
TabsBroadcast.$on('USER-IS-AUTH', (data) => {
    console.log('UserData on event', data)
})

// Will cause a colback and remove the listener. Will be executed only once
TabsBroadcast.$once('USER-IS-AUTH', (data) => {
    console.log('UserData once callback', data)
})

// Removes a listener
TabsBroadcast.$off('USER-IS-AUTH')
2.1.11

5 years ago

2.1.9

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

2.1.2

5 years ago