NodeJS Wait Manager Package
Waiting Manager makes testing for asynchronous calls easy as pie. Originally created to use along with jasmine
specs, to allow waiting for BackboneJS and AngularJS multiple models and views to load before running specs.
Installation
To install simply run:
$ npm install --save node-wait-man
Usage
Instantiation in a regular NodeJS environment would look like this:
waitMan = ; waiterCollection = ; waiter_a = ; waiter_b = ; waiter_a{ return async_complete_a; }; // check for some boolean global variable waiter_b{ return async_complete_b; }; // check for some boolean global variable // Do something when collection of waiters have completed waiterCollection{ // ... }; waiterCollectiontimeout = 300; waiterCollection;
Useful methods and properties:
waiterCollectioninterval // Property which determines in milliseconds how often to poll waiters (default: 100)waiterCollection; // Stop waiting waiterCollectionpending_waiters // Array of pending waiterswaiterCollectionsuccessful_waiters // Array of successful waiterswaiterCollectionaborted_waiters // Array of aborted waiters (includes waiters which have reached timeout limit)
Specs
To run specs, simply install dependencies on root folder of this repo:
$ npm install
and then run the following command:
$ npm test