awaitajax

1.0.0 • Public • Published

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 errresponse

Serial

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

License

MIT

Copyright 2014-2016 Charles Phillips

Package Sidebar

Install

npm i awaitajax

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • doublerebel