Created
November 27, 2014 05:30
-
-
Save ui2code/b1c48a583f9bf797a4e8 to your computer and use it in GitHub Desktop.
Promise - Dojo 1.8.4
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
| require(["dojo/Deferred", "dojo/dom", "dojo/on", "dojo/domReady!"], | |
| function(Deferred, dom, on){ | |
| function asyncProcess(msg){ | |
| var deferred = new Deferred(); | |
| dom.byId("output").innerHTML += "<br/>I'm running..."; | |
| setTimeout(function(){ | |
| deferred.progress("halfway"); | |
| }, 1000); | |
| setTimeout(function(){ | |
| deferred.resolve("finished"); | |
| }, 1500); | |
| setTimeout(function(){ | |
| deferred.reject("ooops"); | |
| }, 2000); | |
| return deferred.promise; | |
| } | |
| on(dom.byId("startButton"), "click", function(){ | |
| var process = asyncProcess(); | |
| process.then(function(results){ | |
| dom.byId("output").innerHTML += "<br/>I'm finished, and the result was: " + results; | |
| }, function(err){ | |
| dom.byId("output").innerHTML += "<br/>I errored out with: " + err; | |
| }, function(progress){ | |
| dom.byId("output").innerHTML += "<br/>I made some progress: " + progress; | |
| }); | |
| }); | |
| }); | |
| var usuario = Ext.create('Usuario', { | |
| nome : 'Hemerson', | |
| senha : 'teste' | |
| }); | |
| console.log( usuario ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment