Skip to content

Instantly share code, notes, and snippets.

@anselmo
Created January 23, 2015 21:14
Show Gist options
  • Save anselmo/49c8a6854676ef216c82 to your computer and use it in GitHub Desktop.
Save anselmo/49c8a6854676ef216c82 to your computer and use it in GitHub Desktop.
<!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>
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