This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* From Paul Irish */ | |
/* instead of */ | |
setInterval(function(){ doStuff(); },100); | |
/* use anonymous self-executing function */ | |
(function thisismyfunctionuniquename(){ | |
doStuff(); | |
setTimeout(thisismyfunctionuniquename,100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @paul_irish Pub/Sub | |
* Works in modern browsers + IE9 | |
* Use Modernizr ployfill for function.bind */ | |
(function($) { | |
var o = $({}); | |
$.subscribe = o.on.bind(o); | |
$.unsubscribe = o.off.bind(o); | |
$.publish = o.trigger.bind(o); | |
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var o = $( {} ); | |
$.each({ | |
trigger: 'publish', | |
on: 'subscribe', | |
off: 'unsubscribe' | |
}, function (key, val) { | |
$[val] = function () { | |
o[key].apply(o, arguments); |