Created
January 23, 2015 21:14
-
-
Save anselmo/49c8a6854676ef216c82 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/petuda
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/q.js/1.0.1/q.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
obj = { | |
list: Q.promised( function(args){ | |
console.log('list'); | |
}), | |
find: Q.promised( function(args){ | |
console.log('find'); | |
}), | |
cache: Q.promised( function(args){ | |
throw new Error('Cache Failed') | |
console.log('cache'); | |
}), | |
decorate: Q.promised( function(args){ | |
console.log('decorate'); | |
}), | |
set: Q.promised( function(args){ | |
console.log('set'); | |
}), | |
response: Q.promised( function(args){ | |
console.log('response'); | |
}) | |
} | |
obj.list( {partner_name: 'partner'} ) | |
.then(obj.cache) | |
.fail(obj.find) | |
.then(obj.decorate) | |
.then(obj.set) | |
.done(obj.response) | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/q.js/1.0.1/q.js"><\/script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript"> obj = { | |
list: Q.promised( function(args){ | |
console.log('list'); | |
}), | |
find: Q.promised( function(args){ | |
console.log('find'); | |
}), | |
cache: Q.promised( function(args){ | |
throw new Error('Cache Failed') | |
console.log('cache'); | |
}), | |
decorate: Q.promised( function(args){ | |
console.log('decorate'); | |
}), | |
set: Q.promised( function(args){ | |
console.log('set'); | |
}), | |
response: Q.promised( function(args){ | |
console.log('response'); | |
}) | |
} | |
obj.list( {partner_name: 'partner'} ) | |
.then(obj.cache) | |
.fail(obj.find) | |
.then(obj.decorate) | |
.then(obj.set) | |
.done(obj.response) | |
</script></body> | |
</html> |
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
obj = { | |
list: Q.promised( function(args){ | |
console.log('list'); | |
}), | |
find: Q.promised( function(args){ | |
console.log('find'); | |
}), | |
cache: Q.promised( function(args){ | |
throw new Error('Cache Failed') | |
console.log('cache'); | |
}), | |
decorate: Q.promised( function(args){ | |
console.log('decorate'); | |
}), | |
set: Q.promised( function(args){ | |
console.log('set'); | |
}), | |
response: Q.promised( function(args){ | |
console.log('response'); | |
}) | |
} | |
obj.list( {partner_name: 'partner'} ) | |
.then(obj.cache) | |
.fail(obj.find) | |
.then(obj.decorate) | |
.then(obj.set) | |
.done(obj.response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment