Skip to content

Instantly share code, notes, and snippets.

@biabsnippets
Created December 6, 2012 13:20
Show Gist options
  • Save biabsnippets/4224404 to your computer and use it in GitHub Desktop.
Save biabsnippets/4224404 to your computer and use it in GitHub Desktop.

Revisions

  1. biabsnippets revised this gist Dec 6, 2012. 1 changed file with 15 additions and 10 deletions.
    25 changes: 15 additions & 10 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,17 @@
    /*
    * Sexy Pub/Sub (jQuery Edition)
    *
    * Hat tip Paul Irish & Jeffrey Way.
    */
    (function($) {
    var o = $({});
    $.each({
    on: 'subscribe',
    trigger: 'publish',
    off: 'unsubscribe'
    }, function(key, api) {
    $[api] = function() {
    o[key].apply(o, arguments);
    }
    });
    var o = $({});
    $.each({
    on: 'subscribe',
    trigger: 'publish',
    off: 'unsubscribe'
    }, function(key, api) {
    $[api] = function() {
    o[key].apply(o, arguments);
    }
    });
    })(jQuery);
  2. biabsnippets created this gist Dec 6, 2012.
    12 changes: 12 additions & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    (function($) {
    var o = $({});
    $.each({
    on: 'subscribe',
    trigger: 'publish',
    off: 'unsubscribe'
    }, function(key, api) {
    $[api] = function() {
    o[key].apply(o, arguments);
    }
    });
    })(jQuery);