cjp

common-js-pub-sub

A minature library for doing pub-sub in the browser.

Showing:

Popularity

Downloads/wk

2

GitHub Stars

2

Maintenance

Last Commit

7yrs ago

Contributors

3

Package

Dependencies

0

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

CommonJS Pub Sub

A very small pub sub library that whole-heartedly stole all it's ideas (and a good chunk of code) from David Walsh. It has been upated so that it will work all the way down to IE8, hence the lack of hasOwnProperty. You can find the original code here.

Install

npm install common-js-pub-sub

Use with Browserify

var events = require('common-js-pub-sub')()

Publish to a topic

events.publish('/page/load', {
    // doesn't have to be a url any key value pairs can be passed here
    url: '/some/url/path'
});

Subscribe to a topic

var subscription = events.subscribe('/page/load', function(obj) {
    // Do something now that the event has occurred
    
    // Note 'obj' represents the object you passed to the publish function
});

Remove said topic

// Toodles
subscription.remove();

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial