Skip to content

Instantly share code, notes, and snippets.

@tobie
Created September 11, 2010 13:05
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 tobie/575166 to your computer and use it in GitHub Desktop.
Save tobie/575166 to your computer and use it in GitHub Desktop.
dojo.safeWhen = function(value, callback, errback, progressHandler) {
var deferred = value;
if (!deferred || typeof deferred.then !== 'function') {
deferred = new dojo.Deferred();
setTimeout(function() { deferred.callback(value); }, 0);
}
return deferred.then(callback, errback, progressHandler);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment