Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Rampaging

Azriel Axighi

💭
Rampaging
View GitHub Profile
@fatihacet
fatihacet / pubsub-simple.js
Created Oct 15, 2011
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
View pubsub-simple.js
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,