New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simplehub

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplehub

[![travis status](https://api.travis-ci.org/finn-no/simplehub.png)](https://travis-ci.org/finn-no/simplehub)

latest
Source
npmnpm
Version
2.2.1
Version published
Maintainers
1
Created
Source

simplehub

travis status

NPM NPM

This is a simple implementation of a publish subscribe module in JavaScript. It can be used in the browser (CommonJS, AMD or just vanilla JS is supported) or on the server as a node module.

Usage

Here is a simple publish subscribe example.

// Subscribe to a topic
var hub = simplehub.create();
hub.subscribe("someTopic", function(data){
	console.log(data.text);
});
// Publish a topic
hub.publish("someTopic", {text: "hello world"});

// You can also use the hub right out of the box, like so
simplehub.publish("..", {});
simplehub.subscribe("..", function(){});

It is possible to have sub topics which provides for a more fine grained approach, below is a sample of how that might look.

var hub = require('../../lib/simplehub/simplehub.js');

hub.subscribe('events/subtopic', function(){
	// Fires only when event with subtopic is present
	console.log('A subtopic event fired');
})
hub.subscribe('events', function(){
	// Fires for both events
	console.log('Just an event fired');
});

hub.publish('events', '');
hub.publish('events/subtopic', '');

FAQs

Package last updated on 30 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts