Skip to content

Instantly share code, notes, and snippets.

@jaubourg
Forked from danheberden/gist:948429
Created April 29, 2011 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaubourg/948434 to your computer and use it in GitHub Desktop.
Save jaubourg/948434 to your computer and use it in GitHub Desktop.
making $.when() always report one arg
var getName = (function() {
var cache; // private cache
// gets assigned to getName
return function() {
// return the cache if it's valid or
return cache || $.ajax({
url: 'srv/echo',
data: { random: 1 },
success: function( data ) {
cache = data;
}
}).pipe( function( res ) {
return res;
});
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment