Skip to content
Tiny event broadcast/receive implementation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
gulpfile.js
package.json
shortwave.js

README.md

shortwave

Simple JavaScript implementation of the broadcast/receive or pub/sub method for sending and receiving events.

It's similar to how you would use $rootScope.$broadcast and $rootScope.$on in AngularJS.

What can you use this repo for? React, for example.

Install

npm install --save shortwave

Usage

You can use it with Browserify so that you can require it on the front-end.

var shortwave = require('shortwave');

var HELLO = 'hello';

var remove = shortwave.on(HELLO, sayHello);

function sayHello() {
    console.log('Hello!');
}

shortwave.emit(HELLO);
// => 'Hello!'

var events = shortwave.get();
console.log(events);
/*
 * {
 *      hello: Array[1];
 * }
 */

shortwave.remove(remove, success, failure);

function success(remainingEvents) {
    console.log('success!')
}

function failure(remainingEvents) {
    console.log('failure');
}       
You can’t perform that action at this time.