Skip to content
last resort in lieu of events or promises
JavaScript
Find file
Latest commit 97b0877 @jokeyrhyme bump version to 1.0.0

README.md

poll-until.js

What?

A last resort in lieu of Events or Promises.

I decided to turn one of my Gists into a reusable component.

/**
 * @param {Function} condition a function that returns `true` or `false`
 * @param {Number} [interval=197] the amount of time to wait between tests
 * @param {Function} callback a function to invoke when the condition returns `true`
 * @returns {Function} call this to stop early (but no earlier than first check)
 */
function pollUntil(condition, interval, callback)`

Where?

Tested in Internet Explorer 6, Node.JS 0.10.28 and Chrome 35. This tiny component is likely to work everywhere.

How?

Can be used as an AMD or Node.JS module, or directly as a browser global.

Browser

bower install poll-until --save
<script src="bower_components/poll-until/poll-until.js"></script>
<script>
pollUntil(/* ... */);
</script>

Node.JS

npm install poll-until --save
var pollUntil = require('poll-until');
pollUntil(/* ... */);
Something went wrong with that request. Please try again.