什么更快:
Event.once('some_event', function() { // wait until an event fired from somewhere
defer.resolve('resolved')
})
...
// somewhere else
Event.emit('some_event')
或类似:
defer = doSmthDeferred(); // to get the deferred resolved/rejected from somewhere else
...
// somewhere else
doSmthDeferred = function() {
defer
if ...
defer.resolve();
else
defer.reject();
}
即:什么是更好的 - 事件处理或嵌套承诺/延迟处理?承诺/延迟是否基于事件处理?