Hostess is a nice girl that will run your async code based on dependencies.
Basic Usage
Calling hostess()
returns a method that you can call repeatedly.
You pass in a name, an optional list of dependencies, and a callback.
The callback will not be called until it's dependcies have been met.
var hostess = host = ; ;
Asynchronous
To use hostess asyncronously, just ask nicely for a callback, and she won't run any dependencies until you call it.
var hostess = host = ; ;
Event Handlers
There are two special names you can give to hostess, 'error'
, and
'done'
, which will act as event handlers and not dependencies.
var hostess = require('hostess') , host = hostess() // if you don't set and error handler, then// errors will be uncaught exceptions.host('error', function(err) { console.log('you got an error: ' + err.message);}); host('bad', function() { throw new Error('oh noes');}); host('bad', function(next) { next(new Error('oh noes'));});
var hostess = host = ; ; ; ;
Debugging
var hostess = host = ;; // defaults to 500ms ; ; /* Outputs:calling depcalling buggybuggy timed out*/