Fork me on GitHub

Ractive.js Promise adaptor plugin

download: Ractive-adaptors-Promise.js more plugins at

This plugin allows adding promises directly as Ractive data objects. The promise will then be replaced by the object it resolved to.

If you're replacing a promise before it resolved to something, the wrapper takes care not to show any intermediate values. This makes it possible to issue requests as the user types something, for example with ractive.observe.

The following demo uses jQuery's AJAX function to query Ractive issues by id from GitHub's api as you type. It uses promise chaining to modify the returned object in the error case.

Two caveats with the demo: It uses CORS, so you need a recent browser. The promise adaptor should work everywhere though. Second, GitHub's anonymous API is heavily rate limited, so you'll get errors if you're clicking around too much.