Permalink
Browse files

docs;

  • Loading branch information...
1 parent f8479ba commit d9b23f2d5e720a4e4b5e16bd49b9698a9e3f7532 @aheckmann committed Jan 9, 2013
Showing with 24 additions and 0 deletions.
  1. +22 −0 README.md
  2. +2 −0 lib/promise.js
View
@@ -161,6 +161,28 @@ p.then(function (arg) {
p.complete(1);
```
+####end
+
+Signifies that this promise was the last in a chain of `then()s`: if a handler passed to the call to `then` which produced this promise throws, the exception will go uncaught.
+
+```js
+var p = new Promise;
+p.then(function(){ throw new Error('shucks') });
+setTimeout(function () {
+ p.fulfill();
+ // error was caught and swallowed by the promise returned from
+ // p.then(). we either have to always register handlers on
+ // the returned promises or we can do the following...
+}, 10);
+
+// this time we use .end() which prevents catching thrown errors
+var p = new Promise;
+var p2 = p.then(function(){ throw new Error('shucks') }).end(); // <--
+setTimeout(function () {
+ p.fulfill(); // throws "shucks"
+}, 10);
+```
+
###Event names
If you'd like to alter this implementations event names used to signify success and failure you may do so by setting `Promise.SUCCESS` or `Promise.FAILURE` respectively.
View
@@ -253,6 +253,8 @@ Promise.prototype.then = function (onFulfill, onReject) {
* setTimeout(function () {
* p.fulfill(); // throws "shucks"
* }, 10);
+ *
+ * @api public
*/
Promise.prototype.end = function () {

0 comments on commit d9b23f2

Please sign in to comment.