Created
February 9, 2013 04:27
-
-
Save aramk/4743839 to your computer and use it in GitHub Desktop.
Wraps a function in a dojo.Deferred object.
This file contains hidden or 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
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