Skip to content

Instantly share code, notes, and snippets.

@shrikanthkr
Last active August 29, 2015 14:04
Show Gist options
  • Save shrikanthkr/f72f697a8002aacf74d9 to your computer and use it in GitHub Desktop.
Save shrikanthkr/f72f697a8002aacf74d9 to your computer and use it in GitHub Desktop.
Sample for using promises
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