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

0.1.1 • Public • Published

tabcast

TypeScript message passing (broadcasting) across multiple tabs of same origin.

workflow npm npm NPM

Installation

Tabcast is available on npm, you can install it with either npm or yarn:

npm install tabcast
# or: 
yarn install tabcast

Example usage

import Tabcast from 'tabcast';
 
const cast = new Tabcast(); // or new Tabcast('channel');
 
cast.on('message', (message: any) => {
  console.log(message);
});
 
cast.broadcast('Hello, world!');

Events

message

Emitted when a valid message is received.

The only argument contains an object of type T with a deserialized message.

API

on(eventType: 'message', listener: (message: T) => void);

off(eventType: 'message', listener: (message: T) => void);

constructor(private channel: string);
broadcast(message: T);

Package Sidebar

Install

npm i tabcast

Weekly Downloads

695

Version

0.1.1

License

BSD-3-Clause-Clear

Unpacked Size

8.87 kB

Total Files

9

Last publish

Collaborators

  • mat-sz