我有两个抽象进程(例如,在js对象中使用揭示模式进行管理,不暴露其内部),它们在完成时会触发自定义事件。当这两个自定义事件都触发时,我想执行一个操作。
jQuery 1.5中的新Deferred逻辑似乎是管理此过程的理想方式,但是when()方法需要返回一个promise()的Deferred对象(或普通js对象,但是then()将立即完成而没有等待的效果,对我来说是无用的)。
理想情况下,我想做这样的事情:
什么是将这两种技术结合在一起的最佳方式?
jQuery 1.5中的新Deferred逻辑似乎是管理此过程的理想方式,但是when()方法需要返回一个promise()的Deferred对象(或普通js对象,但是then()将立即完成而没有等待的效果,对我来说是无用的)。
理想情况下,我想做这样的事情:
//execute when both customevent1 and customevent2 have been fired
$.when('customevent1 customevent2').done(function(){
//do something
});
什么是将这两种技术结合在一起的最佳方式?