/paper-pusher

Tiny frontend pub/sub component

Primary LanguageJavaScriptMIT LicenseMIT

paper-pusher

Tiny pub/sub messaging component with no dependencies.

Install

npm install paper-pusher

Importing

PaperPusher can be consumed via importing the ES module:

import { PaperPusher } from 'paper-pusher'

Alternatively, a minified distribution file, for use in all modern browsers is available at dist/paper-pusher.min.js

Initialize

const eventSystem = new PaperPusher();

Publish

const eventData = {};
eventSystem.publish('event-name', eventData);

Subscribe

eventSystem.subscribe('event-name', function(eventData) {
    // 'event-name' event emitted, do something...
});