Skip to content
matthewp edited this page Jul 12, 2012 · 20 revisions

Q + Mongoose, as an example of adapting Node code. Based on this Stack Overflow question.

Q + node_redis, as an example of adapting the node_redis operations to Q (Coffeescript)

Flickr API Experiments, as an example of adapting jQuery Ajax promises for a JSONP API. Uses deferreds, the get utility, Q.all, and chaining.

Basic Chaining Example, showing how promises compose. Also illustrates Q.ncall as an alternative to using deferreds when working with Node.

Promises in a UI Context, a somewhat extensive and complicated "real world" example from @domenic's work at Barnes & Noble.com. Includes some helper functions to create alert/confirm/prompt dialogs that communicate their results via promises; adapts jQuery Ajax promises; and shows how to intercept and "re-throw" rejections at system boundaries.

Using Array.reduce to make your own Q.all. This doesn’t work as well as Q.all or Q.allResolved, but I found it very instructive in discovering how promises can be composed.

A very simplistic HTTP proxy

A simplistic HTTP "queue" application Where POST puts a request’s actively streaming body into the queue and GET pipes the request’s body to the response’s body.

How to adapt the XHR interface to an HTTP.read(url) that returns a Q

Control flow emulating "break" out of a loop of promises

Retry a some times with a delay between attempts

Old Narwhal code that illustrates functional composition of promises But definitely would not run today without some modifications.

XMLHttpRequest wrapped into a promise