wavestation

1.0.1 • Public • Published

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();

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i wavestation

    Weekly Downloads

    127

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • inventingwithmonster