1.0.1 • Published 9 years ago

wavestation v1.0.1

Weekly downloads
10
License
MIT
Repository
github
Last release
9 years ago

Wavestation

A simple pub/sub CommonJS module, based on David Walsh's module @ http://davidwalsh.name/pubsub-javascript

Install

File include

Download the latest wavestation.global.js from http://github.com/InventingWithMonster/wavestation and include it in your HTML document with a script tag, ie:

<script src="/path/to/wavestation.global.js"></script>

This will load Wavestation to the globally-accessible variable wavestation.

NPM (recommended)

First install Wavestation in your project root.

$ npm install wavestation

Then include in your module using require().

var wavestation = require('wavestation');

Use

Listen

var listener = wavestation.listen('your-channel', function (data) {
    console.log(data);
}); // Will log data when 'your-channel' broadcasts

Broadcast

wavestation.broadcast('your-channel', { foo: bar }); // Broadcasts to 'your-channel'

Create broadcaster

var yourChannel = wavestation.newBroadcast('your-channel');

yourChannel({ foo: bar }); // Broadcasts to 'your-channel'

Remove listener

listener.remove();
1.0.1

9 years ago

1.0.0

9 years ago