Skip to content

Commit

Permalink
Clarify some of the "The Beginning" section.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed May 16, 2012
1 parent cedc3f9 commit 23320b0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ Everything above assumes you get a promise from somewhere else. This
is the common case. Every once in a while, you will need to create a
promise from scratch.

#### Using ``Q.fcall``

You can create a promise from a value using ``Q.fcall``. This returns a
promise for 10.

Expand All @@ -428,6 +430,9 @@ numbers.
return Q.fcall(eventualAdd, 2, 2);
```


#### Using Deferreds

When nothing else will do the job, you can use ``defer``, which is
where all promises ultimately come from.

Expand All @@ -448,6 +453,10 @@ Note that a deferred can be resolved with a value or a promise. The
promise.

```javascript
// this:
deferred.reject(new Error("Can't do it"));

// is shorthand for:
var rejection = Q.fcall(function () {
throw new Error("Can't do it");
});
Expand Down

0 comments on commit 23320b0

Please sign in to comment.