A deferred factory object
Defector allows creating deferred objects with a many-to-many relationship between queues and resolvers. By creating this type of event map there shouldn't be a need for callback insanity. Here's an example:
var dobj = defactor;dobjadd 'done' 'resolve'add 'fail' 'reject'add 'always' 'resolve'add 'always' 'reject' ;var defer = dobjcreate;deferdoneconsole.log 'done' ;failconsole.log 'fail' ;alwaysconsole.log 'always' ;;deferresolve; // LOG: "done"; "always"
promise()method to each deferred
addWith()to create queue/resolver pairs that accept a new context
create()should return an uninstantiated deferred
always()method to create a queue that is always fired
then()that accepts two queues and resolvers