oncejs

1.0.2 • Public • Published

once npm downloads Standard - JavaScript Style Guide

Simple module that allows calling a function once until it's done

npm

npm install oncejs

bower

bower install once

usage

Using axios (third-party) as http library.

//...
var once = require('once'), axios = require('axios');
 
var sendRequest = once(function (done) {
    axios('www.site.com/api/users').then(resolveResponse).catch(resolveError).then(done);
});
 
document.getElementById('button').addEventListener('click', sendRequest);

Multiple clicks on #button won't result in new http requests unless the started request has been resolved.

license

MIT. Copyright (c) 2017 Isaac Ferreira (zaclummys)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i oncejs

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • zaclummys