npm.io
1.2.0 • Published 4 years ago

paper-pusher

Licence
MIT
Version
1.2.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0

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...
});