Recant
A promise library that violates everything you know about promises.
Things You Can Do
*Create promises where the resolver can reset the promise to resolve/reject again.
*Create deferreds that can be reset to resolve/reject again. Again
Why on earth would you do this?
*Create a promise that always resolves with an open connection (reset the promise on conn.close or conn.err)
*Pipeline dynamic dependencies through normal promise symantics
Usage
Install via NPM
$ npm install recant
Example- Promise
var recant = require('recant') ;
var promise = recant.promise(function(resolve,reject,notify,reset){
var connPromise = connection.open() ;
connPromise.then(function(conn){
resolve(conn) ;
conn.on('close',reset) ;
}).then(null,function(err){
reject(err) ;
})
})
Example- Deferred
var recant = require('recant') ;
var deferred = recant.defer() ;
var promise = deferred.promise ;
deferred.resolve(val);
deferred.reset() ;
deferred.reject(err) ;