1.0.0 • Published 5 years ago

wrecked-radio v1.0.0

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

WreckedRadio

CircleCI Coverage Status

WreckedRadio is a message bus implementation that supports both publish-subscribe and request-reply patterns. It's:

  • Written in modern TypeScript
  • Fully covered with tests
  • As tiny as possible
  • Dependency free

Heavily inspired by backbone.radio.

Getting started

Installation

yarn add wrecked-radio

or

npm install --save wrecked-radio

Import and instantiation

import WreckedRadio from 'wrecked-radio';

const radio = new WreckedRadio();
const firstChannel = radio.channel('first-channel');
const secondChannel = radio.channel('second-channel');

Event passing

// Somewhere in event subscriber:
channel.on('user-login-success', user => console.log(`Oh, hi ${user.name}`);

// Somewhere in event publisher:
channel.trigger('user-login-success', { name: 'Mark' });

Request passing

// Somewhere in command processor:
channel.reply('get-greeting', user => `Oh, hi ${user.name}`);

// Somewhere else:
const greeting = channel.request('get-greeting', { name: 'Mark' });

Links

Detailed API Reference

Licensing

MIT License

1.0.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago