1.0.0 • Published 7 years ago
@skumtron/poll v1.0.0
Poll
When all you need to do is poll a HTTP resource. A tiny, TINY polling library.
Installation
Embed lib/poll.js
to your project or add it through CDN:
<script src="https://unpkg.com/@skumtron/poll/lib/poll.js"></script>
Alternatively install it through npm:
npm install @skumtron/poll
Usage
Takes an object with following properties as it's argument
var postsPoll = poll({
url: "https://api.example.com/posts/",
onResponse: function(res) {
// handle response
},
onError: function(err) {
// handle errors
},
interval: 5000, // Optional, defaults to 10000
autoStart: false // Optional, defaults to true
});
Returns an object with following (self explanatory) methods
postsPoll.start();
postsPoll.stop();
License
This project is licensed under the MIT License - see the LICENSE file for details