Last active
August 29, 2015 14:04
-
-
Save shrikanthkr/f72f697a8002aacf74d9 to your computer and use it in GitHub Desktop.
Sample for using promises
This file contains 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
function promise(arg){ | |
return new Promise(function(resolve,reject){ | |
if(arg) | |
resolve(arg); | |
else | |
reject('Error'); | |
}); | |
} | |
setTimeout(function(){ | |
promise('Shrikanth').then(function(res){ | |
console.log('Hello '+res); | |
},function(err){ | |
console.log(err) | |
}); | |
},2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment