Last active
January 2, 2016 10:49
-
-
Save andrewwakeling/8292941 to your computer and use it in GitHub Desktop.
Comparing error reporting with Promise libraries
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
var foo = function () { | |
var promise = new Promise(function (resolve, reject, notify) { | |
setTimeout(function () { | |
resolve(); | |
}, 100); | |
}); | |
return promise; | |
}; |
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="bower_components/bluebird/js/browser/bluebird.js"></script> | |
<script src="bluebird-foo.js"></script> | |
<script src="invoke-foo.js"></script> | |
</head> | |
</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
{ | |
"name": "compare-promises", | |
"version": "0.0.1", | |
"dependencies": { | |
"rsvp": "3.0.1", | |
"q": "1.0.0", | |
"bluebird": "0.11.6-1" | |
} | |
} |
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
foo().then(function () { | |
// The following code will cause an error. | |
var undefinedFunc = undefined; | |
undefinedFunc(null); | |
}, function (error) { | |
// This is defined for best practice only. We shouldn't be getting here. | |
debugger; | |
}); |
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
var foo = function () { | |
var promise = new Q.promise(function (resolve, reject, notify) { | |
setTimeout(function () { | |
resolve(); | |
}, 100); | |
}); | |
return promise; | |
}; |
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="bower_components/q/q.js"></script> | |
<script src="q-foo.js"></script> | |
<script src="invoke-foo.js"></script> | |
</head> | |
</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
/** | |
* It is acknowleged that you can handle uncaught errors by running the following code. By default though, RSVP should not silence errors. | |
* | |
* RSVP.configure('onerror', function(e) { | |
* console.log(e.message); | |
* console.log(e.stack); | |
* } | |
*/ | |
var foo = function () { | |
var promise = new RSVP.Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve(); | |
}, 100); | |
}); | |
return promise; | |
} |
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="bower_components/rsvp/rsvp.js"></script> | |
<script src="rsvp-foo.js"></script> | |
<script src="invoke-foo.js"></script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment