Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/holdspartans
A function list that will hold their position until a status bit is changed
https://github.com/binocarlos/holdspartans
Last synced: 11 days ago
JSON representation
A function list that will hold their position until a status bit is changed
- Host: GitHub
- URL: https://github.com/binocarlos/holdspartans
- Owner: binocarlos
- Created: 2013-12-13T17:20:54.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-13T18:06:09.000Z (almost 11 years ago)
- Last Synced: 2024-11-07T14:02:53.113Z (13 days ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
holdspartans
============A function list that will hold their position until a status bit is changed
An example of waiting until we have a connection before sending requests:
```js
var Spartans = require('holdspartans');
var connection = new Connection(...);var spartans = new Spartans();
function run_request(req, res){
// wrap the function so it is only run once the connection is active
spartans.add(function(){
connection.send(req, res);
})
}connection.on('connect', function(){
// this lets new functions through and runs the function in the buffer
spartans.hold(false);
})connection.on('connect', function(){
// this starts buffering functions again
spartans.hold(true);
})
```## licence
MIT