Pancake/French Toast/IO

From MozillaWiki
Jump to: navigation, search

User Scenarios

As a front-end developer, I need a way to send requests and receive responses asynchronously.

AJAX wrapper.

As a front-end developer, I need multiple parties to be able to receive responses so that I can react to relevant information in many parts of the program. I need to be able to decorate requests with multiple parties so I can add auth tokens to requests, etc.

These are both perfect candidates for middleware. The simplest approach to filtering middleware is function composition.

Promises are composed functions with specific tools for dealing with eventual values. Returning a promise for the response of an IO request solves the request case, but does not solve the request decoration case.