/node-awaitajax

Turns Node http.request into single-callback form, for use with await/defer

Primary LanguageCoffeeScript

awaitajax

Build Status Coverage Status Dependency Status devDependency Status Downloads

Turns Node http.request into single-callback form, for use with await/defer

NPM

What?

Iced CoffeeScript and tamejs offer the await/defer construct that lends itself well to the node-style async pattern callback(err, response), particularly when using a construct like make_esc from iced error.

awaitajax lets you have your await and easy jQuery.ajax() -style options too. By building on najax http calls can be easily handled in one line.

Background and related modules

awaitajax started as a great exercise in using iced.Rendezvous() and iced.Pipeliner(), the first-callback-wins and serial-call helper features of Iced. The original version was created for TigerJS, an MVC framework for cross-platform Titanium mobile apps built in JavaScript/CoffeeScript. Now I can't live without this pattern in node, mobile apps, and the browser.

Example

Regular

await Ajax.awaitGet {url: "https://www.google.com"}, defer err, response

Serial

await Ajax.awaitQueuedGet {url: "https://www.google.com"}, defer err, response
await Ajax.awaitQueuedGet {url: "http://siteaftergoogle.com"}, defer err, response

License

MIT

Copyright 2014-2016 Charles Phillips