Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Minimalist publish/subscribe.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 dist
Octocat-spinner-32 spec
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .jshintrc
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Makefile
Octocat-spinner-32 UNLICENSE
Octocat-spinner-32 component.json
Octocat-spinner-32 package.json


sublish is a minimalist lightweight (504 Bytes minified and 297 Bytes gzipped) implementation of publish/subscribe.

stability 3 - stable license - Unlicense Flattr this

browser support

Build Status Coverage Status Dependencies

NPM status



With NPM

npm install sublish

From source

git clone
cd sublish
npm install
make && make dist


With component

component install pluma/sublish

Learn more about component.

With bower

bower install sublish

Learn more about bower.

With a CommonJS module loader

Download the latest minified CommonJS release and add it to your project.

Learn more about CommonJS modules.

With an AMD module loader

Download the latest minified AMD release and add it to your project.

Learn more about AMD modules.

As a standalone library

Download the latest minified standalone release and add it to your project.

<script src="/your/js/path/sublish.globals.min.js"></script>

This makes the sublish module available in the global namespace.

Basic usage example

var myPubSub = new sublish.PubSub();

myPubSub.subscribe(function(message) {
  console.log('myPubSub says: "' + message + '"');

// elsewhere
myPubSub.publish('something amazing');
// -> 'myPubSub says: "something amazing"'

Mixin usage example with mixed

function Person(name) { = name;
Person.prototype = {
    say: function(message) {
        this.publish( + ' says: "' + message + '"');

var joe = new Person('Joe');
mixed.mixin(sublish.PubSub, joe);

joe.subscribe(function(message) {

// elsewhere
joe.say('Hello there!');
// -> 'Joe says: "Hello there!"


new PubSub()

Creates a new PubSub instance.

NOTE: This is a constructor. Use of the new keyword is therefore not optional.


Adds the given callback function to this object's list of subscribers.

NOTE: The callback will be called with the PubSub instance as its context. If you want to preserve the callback's original context, use Function#bind or (in legacy browsers) wrap the callback in a closure.


Removes the given callback function from this object's list of subscribers.


Publishes the given arguments as a message. Every callback function in this object's list of subscribers will be called sequentially with the given messages as its arguments.


This is free and unencumbered public domain software. For more information, see or the accompanying UNLICENSE file.

Something went wrong with that request. Please try again.