Skip to content

Instantly share code, notes, and snippets.

@aramk
Created February 9, 2013 04:27
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 aramk/4743839 to your computer and use it in GitHub Desktop.
Save aramk/4743839 to your computer and use it in GitHub Desktop.
Wraps a function in a dojo.Deferred object.
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/Deferred'
], function (declare, lang, Deferred) {
return declare([Deferred], {
// summary:
// Wraps a function in a dojo.Deferred object.
// The result of the callback - can be another Deferred object
inner: null,
constructor: function (/*Function*/ callback) {
// summary:
// Creates a Deferred which calls the callback when resolved.
this.then(lang.hitch(this, function() {
this.inner = callback();
}));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment