@tawaship/transceiver
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@tawaship/transceiver

A module for mutual messaging between multiple objects.

Build Status MIT License


Setup

NPM

npm install --save @tawaship/transceiver

import { Transceiver } from '@tawaship/transceiver';

Browser

git clone https://github.com/tawaship/Transceiver

<script src="/path/to/dist/Transceiver.min.js"></script>

Usage

Create transceivers

const [ A, B, C ] = Transceiver.create(3);

Listen event

A.on('hoge', e => {
	console.log('A');
});

B.on('moge', e => {
	console.log('B');
});

C.on('fuga', e => {
	console.log('C');
});

Send event

Note that unlike a typical Emitter, it does not fire an event to itself.

A.emit('hoge'); // (nothing)
A.emit('moge'); // B
A.emit('fuga'); // C
B.emit('hoge'); // A
B.emit('moge'); // (nothing)
B.emit('fuga'); // C
C.emit('hoge'); // A
C.emit('moge'); // B
C.emit('fuga'); // (nothing)

Package Sidebar

Install

npm i @tawaship/transceiver

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

89.6 kB

Total Files

13

Last publish

Collaborators

  • tawaship