Skip to content
Browse files

Merge pull request #1 from phobia/patch-1

Only trigger topic if there are subscribers to it
  • Loading branch information...
2 parents 2e48d3e + ca8006c commit d296179cd565d30a5adf7b5cd736becc0c46fd83 @martinjuhasz committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 pubsub.js
View
8 pubsub.js
@@ -28,9 +28,11 @@
// with a function signature like: function(a,b,c){ ... }
//
// | $.publish("/some/topic", ["a","b","c"]);
- cache[topic].forEach(function(property){
- property.apply($, args || []);
- });
+ if(typeof cache[topic] === 'object') {
+ cache[topic].forEach(function(property){
+ property.apply($, args || []);
+ });
+ }
};
$.subscribe = function(/* String */topic, /* Function */callback){

0 comments on commit d296179

Please sign in to comment.
Something went wrong with that request. Please try again.